SetAttr-udtryk

Sæt attributinformation for en angivet fil.

Syntaks:


SetAttr PathName As String, Attributes As Integer

Parametre:

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:

Navngivet konstant

Værdi

Definition

ATTR_NORMAL

0

Almindelige filer.

ATTR_READONLY

1

Skrivebeskyttede filer.

ATTR_HIDDEN

2

Skjult fil


Du kan sætte flere attributter ved at kombinere de respektive værdier med en logisk OR sætning.

Fejlkoder:

5 Ugyldigt Procedurekald

53 Fil ikke fundet

70 Adgang nægtet

Eksempel:


Sub ExampleSetGetAttr
 On Error Goto ErrorHandler REM Definer mål for fejlhåndtering
 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

Støt os venligst!