Instrucción SetAttr

Configura la información de atributo de un archivo especificado.

Sintaxis:


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 con nombre

Valor

Definición

ATTR_NORMAL

0

Archivos normales.

ATTR_READONLY

1

Archivos de solo lectura.

ATTR_HIDDEN

2

Archivo oculto


Puede establecer varios atributos combinando los valores respectivos con una instrucción OR lógica.

Códigos de error:

5 Llamada a procedimiento no válida

53 Archivo no encontrado

70 Acceso denegado

Ejemplo:


Sub ExampleSetGetAttr
 On Error GoTo ErrorHandler ' Definir el destino para el manipulador de errores
 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

¡Necesitamos su ayuda!