Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IO.File.GetAttributes
Message
De
22/07/2005 17:27:48
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
22/07/2005 16:31:30
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01035284
Message ID:
01035301
Vues:
13
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform