Instrução SetAttr

Define as informações dos atributos de um ficheiro especificado.

Sintaxe:


SetAttr PathName As String, Attributes As Integer

Parâmetros:

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 com nome

Valor

Definição

ATTR_NORMAL

0

Ficheiros normais.

ATTR_READONLY

1

Ficheiros só de leitura.

ATTR_HIDDEN

2

Ficheiro oculto


Para definir vários atributos, combine os respetivos valores com uma instrução lógica OR.

Códigos de erro

5 Chamada de procedimento inválido

53 Ficheiro não encontrado

70 Acesso recusado

Exemplo:


Sub ExampleSetGetAttr
 On Error GoTo ErrorHandler ' Definir alvo para o tratamento de erros
 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

Necessitamos da sua ajuda!