Инструкция SetAttr

Задаёт данные атрибута для указанного файла.

Синтаксис:


SetAttr PathName As String, Attributes As Integer

Параметры:

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:

Именованная константа

Значение

Определение

ATTR_NORMAL

0

Обычные файлы.

ATTR_READONLY

1

Файлы только для чтения.

ATTR_HIDDEN

2

Скрытый файл


Можно задать несколько атрибутов, объединяя соответствующие значения с использованием логической инструкции OR.

Коды ошибок:

5 Неправильный вызов процедуры

53 Файл не найден

70 Доступ запрещён

Пример:


Sub ExampleSetGetAttr
 On Error Goto ErrorHandler REM Определение расположения для обработчика ошибок
 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

Пожалуйста, поддержите нас!