Name

SetAttr Procedure — Microsoft.VisualBasic.FileSystem

Synopsis

SetAttr(pathname, attributes)
pathname required; String

The name of the file or directory whose attributes are to be set

attributes required; FileAttribute enumeration

Numeric expression, FileAttribute enumerated constant, or global VB constant specifying the attributes

Description

Changes the attribute properties of a file.

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 to FileAttribute.Normal. The file-attribute constants vbDirectory, vbAlias, and vbVolume cannot 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

Get VB.NET Language Pocket Reference 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.