GetAttr Function

Devolve un patrón de bits que identifica o tipo de ficheiro ou o nome dun volume ou dun cartafol.

Sintaxe:

GetAttr (Texto As String)

Valor de retorno:

Enteiro

Parámetros:

Text: Any string expression that contains an unambiguous file specification. You can also use URL notation.

Esta función determina os atributos dun ficheiro especificado e devolve o patrón de bits que pode axudar a identificar os seguintes atributos de ficheiro:

Códigos de erro

5 Chamada de procedemento incorrecta

53 Ficheiro non atopado

Valor

Named constant

Value

Definition

ATTR_NORMAL

0

Normal files.

ATTR_READONLY

1

Read-only files.

ATTR_HIDDEN

2

Hidden file

ATTR_SYSTEM

4

System file

ATTR_VOLUME

8

Returns the name of the volume

ATTR_DIRECTORY

16

Returns the name of the directory only.

ATTR_ARCHIVE

32

File was changed since last backup (Archive bit).


Se desexa saber se está activado algún bit do byte de atributo, use o método de consulta seguinte:

Exemplo:

Sub ExampleSetGetAttr

On Error Goto ErrorHandler REM Define target for error-handler

 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" ,1

 Print GetAttr( "c:\test\autoexec.sav" )

 End

ErrorHandler:

 Print Error

 End

End Sub