Instruction SetAttr

Définit les informations relatives aux attributs d'un fichier particulier.

Syntaxe :


SetAttr PathName As String, Attributes As Integer

Paramètres :

FileName: Name of the file, including the path, that you want to test attributes of. If you do not enter a path, SetAttr searches for the file in the current directory. You can also use URL notation.

Attributes: Bit pattern defining the attributes that you want to set or to clear:

Constante nommée

Valeur

Définition

ATTR_NORMAL

0

Fichiers normaux.

ATTR_READONLY

1

Fichiers en lecture seule.

ATTR_HIDDEN

2

Fichier caché


Vous pouvez définir plusieurs attributs en combinant les valeurs respectives avec une instruction OR logique.

Codes d'erreur :

5 appel de procédure incorrect

53 fichier non trouvé

70 accès refusé

Exemple :


Sub ExampleSetGetAttr
 On Error Goto ErrorHandler ' Définir une cible pour le gestionnaire des erreurs
 If Dir("C:\test",16)="" Then MkDir "C:\test"
 If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav"
 SetAttr "c:\test\autoexec.sav" ,0
 FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav"
 SetAttr "c:\test\autoexec.sav" , ATTR_READONLY
 Print GetAttr( "c:\test\autoexec.sav" )
 End
ErrorHandler:
 Print Error
 End
End Sub