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 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" , ATTR_READONLY
 Print GetAttr( "c:\test\autoexec.sav" )
 End
ErrorHandler:
 Print Error
 End
End Sub