Name
SetAttr Procedure
Class
Microsoft.VisualBasic.FileSystem
Syntax
SetAttr(pathname,attributes)
-
pathname(required; String) The name of the file or directory whose attributes are to be set
-
attributes(required;FileAttributeenumeration) Numeric expression,
FileAttributeenumerated 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
VbNormal0
Normal
VbReadOnly1
Read-only
VbHidden2
Hidden
VbSystem4
System
VbArchive32
File has changed since last backup
Each global constant has a corresponding constant in the
FileAttributeenumeration. For example,vbNormalis identical toFileAttribute.Normal. The file-attribute constantsvbDirectory,vbAlias, andvbVolumecannot be used when assigning attributes.File-attributes constants can be
Ored to set more than one attribute at the same time. For example:SetAttr "SysFile.Dat", FileAttribute.System Or FileAttribute.Hidden
pathnamecan 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.pathnamecan 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 a runtime error.
Example ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access