SetAttr utasítás

Beállítja egy megadott fájl attribútuminformációját.

Szintaxis:


SetAttr PathName As String, Attributes As Integer

Paraméterek:

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:

Nevesített konstans

Érték

Definíció

ATTR_NORMAL

0

Normál fájlok.

ATTR_READONLY

1

Csak olvasható fájlok.

ATTR_HIDDEN

2

Rejtett fájl


Különböző attribútumokat is megadhat a megfelelő értékek logikai OR utasítással történő összekapcsolásával.

Hibakódok:

5 Érvénytelen eljáráshívás

53 A fájl nem található

70 Hozzáférés megtagadva

Példa:


Sub ExampleSetGetAttr
 On Error GoTo ErrorHandler ' Definiálja a hibakezelő függvényt
 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

Támogasson minket!