Comparing FileInfo.FileAttributes

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

I am having some trouble comparing file attributes because there can sometimes be more than one attribute assigned to a specific file or directory.

So how would i write in vb this:

if (one of the file attributes is hidden) Then
...do something....
end if

Thanks.
 
You need to do a bitwise AND operation with the Attributes compound value to see only the hidden flag:
VB.NET:
Dim f As New IO.FileInfo("filepath")
If (f.Attributes And IO.FileAttributes.Hidden) = IO.FileAttributes.Hidden Then

End If
 
Ok i'm not really with you, but i will google "bitwise operations" and i'll post back if i still need help.

Thanks.
 
Back
Top