SetAttr Statement

指定ファイルの属性情報を設定します。

Syntax:


SetAttr PathName As String, Attributes As Integer

Parameters:

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:

Named constant

Value

Definition

ATTR_NORMAL

0

Normal files.

ATTR_READONLY

1

Read-only files.

ATTR_HIDDEN

2

Hidden file


これらの属性値は、論理演算用の OR ステートメントと組み合わせて指定することもできます。

Error codes:

5 無効なプロシージャー呼び出しです

53 ファイルが見つかりません

70 アクセスが拒否されました

Example:


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

ご支援をお願いします!