Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# check if a directory is hidden? [duplicate]

Possible Duplicate:
How to test if directory is hidden in C#?

DirectoryInfo dir = new DirectoryInfo(@"c:\test");
if ((dir.Attributes & FileAttributes.Hidden) == (FileAttributes.Hidden)) 
{ 
     //do stuff
}

With this if statement i would like to test if the directory is hidden. Although the directory really is hidden, my program doesn't get into the do stuff because only the directory flag of the attributes is set. Any suggestions?

like image 341
user436238 Avatar asked Aug 31 '10 18:08

user436238


1 Answers

Try this:

DirectoryInfo dir = new DirectoryInfo(@"c:\test");
if ((dir.Attributes & FileAttributes.Hidden) != 0)
{
   //do stuff
}
like image 84
Garis M Suero Avatar answered Oct 06 '22 18:10

Garis M Suero