Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IO.File.GetAttributes
Message
From
22/07/2005 17:27:48
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
22/07/2005 16:31:30
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01035284
Message ID:
01035301
Views:
12
This message has been marked as the solution to the initial question of the thread.
>I am using the get attributes method to determine if a file is readonly. Using the code posted below on a file that I know to be read only the code below is not executed.
>
>  If IO.File.GetAttributes(lcfile) <> IO.FileAttributes.ReadOnly Then
>console.writeline(lcfile & " is a readonly file")
>  End If
>
>So to test a bit further I used this code which returns a value of ReadOnly,Archive
>
>  Dim oattrib As IO.FileAttributes
>      oattrib = IO.File.GetAttributes(lcfile)
>console.writeline(oattrib.ToString)
>
>
>So I could modify top code to be
>
If IO.File.GetAttributes(lcfile) <> IO.FileAttributes.ReadOnly + IO.FileAttributes.Archive Then
>
>But what I would like to do is be able to tell if it is readonly and do not care if it is archive system etc.
>
>Any suggestions?
>Thanks
>Paul

Paul,

The key to isolating the ReadOnly bit in the bit-flag is to bitwise-AND the value with IO.FileAttributes.ReadOnly (0x0001).
If (IO.File.GetAttributes(lcFile) And IO.FileAttributes.ReadOnly) = IO.FileAttributes.ReadOnly Then
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform