Problem with And operator

TechnoTone

Well-known member
Joined
Jan 20, 2003
Messages
224
Location
UK - London
Whats wrong with the following line (VB.NET):

Code:
If myFileInfo.Attributes And IO.FileAttributes.ReadOnly Then
Im getting the error:
"Option Strict On disallows implicit conversions from System.IO.FileAttributes to Boolean."
 
Its saying you must explicitly add the " = true " to your conditionals, ie:
IO.FileAttributes.ReadOnly = True
 
Thanks. I knew it would be obvious. The correct line is:

Code:
If CType((myFileInfo.Attributes And IO.FileAttributes.ReadOnly), Boolean) Then
 
The myFileInfo.Attributes is of type System.IO.FileAttributes, not boolean. You have to make it into a boolean statement. like

Code:
myFileInfo.Attributes is nothing
 
Back
Top