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 Invalid procedure call

53 File not found 53 File not found

70 Permission denied

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

Please support us!