Name
SetAttr Procedure
Class
Microsoft.VisualBasic.FileSystem
Syntax
SetAttr(pathname, attributes
)
-
pathname
Use: Required
Data Type: String
The name of the file or directory whose attributes are to be set
-
attributes
Use: Required
Data Type:
FileAttribute
enumerationNumeric expression,
FileAttribute
enumerated constant, or global VB constant specifying the attributes
Description
Changes the attribute properties of a file
Rules at a Glance
You can use any sum of the following constants to set the attributes of a file:
Constant
Value
Description
VbNormal
0
Normal
VbReadOnly
1
Read-only
VbHidden
2
Hidden
VbSystem
4
System
VbArchive
32
File has changed since last backup
Each global constant has a corresponding constant in the
FileAttribute
enumeration. For example,vbNormal
is identical toFileAttribute.Normal
. The file-attribute constantsvbDirectory
,vbAlias
, andvbVolume
cannot be used when assigning attributes.File-attributes constants can be
Or
ed to set more than one attribute at the same time. For example:SetAttr "SysFile.Dat", FileAttribute.System Or FileAttribute.Hidden
pathname
can include a drive letter. If a drive letter is not included inpathname
, the current drive is assumed. The file path can be either a fully qualified path or a relative path from the current directory.pathname
can include a folder name. If the folder name is not included inpathname
, the current folder is assumed.Attempting to set the attributes of an open file will generate ...
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.