Expressió SetAttr

Estableix la informació d'atribut d'un fitxer especificat.

Sintaxi:


SetAttr PathName As String, Attributes As Integer

Paràmetres :

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:

Constant amb nom

Valor

Definició

ATTR_NORMAL

0

Fitxers normals.

ATTR_READONLY

1

Fitxers de només de lectura.

ATTR_HIDDEN

2

Fitxer ocult


Podeu definir diferents atributs combinant els valors respectius amb una expressió OR lògica.

Codis d'error

5 La crida al procediment no és vàlida

53 No s'ha trobat el fitxer

70 S'ha denegat l'accés

Exemple :


Sub ExampleSetGetAttr
 On Error Goto ErrorHandler ' Defineix la destinació per al gestor d'errors
 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

Ens cal la vostra ajuda!