SetAttr Procedure


SetAttr Procedure

Class

Microsoft.VisualBasic.FileSystem

Syntax

     SetAttr(pathname, attributes) 


pathname (required; String)

The file or directory whose attribute details are to be set.


attributes (required; FileAttribute enumeration)

One or more of the following Microsoft.VisualBasic.FileAttribute enumeration values, added or Or'd together. Each member also has a related Visual Basic intrinsic constant that can be used instead.

Enumeration

Constant

Description

Normal

vbNormal

Normal file (the absence of other attributes)

ReadOnly

vbReadOnly

Read-only file

Hidden

vbHidden

Hidden file

System

vbSystem

System file

Archive

vbArchive

File has changed since the last backup


Description

The SetAttr procedure modifies the attributes of a file or directory.

Usage at a Glance

  • pathname can be either an absolute or relative path to a file. It can exist on the local or remote drive and can use the drive-letter or UNC path format.

  • An error occurs if pathname is invalid or cannot be found.

  • Attempting to set the attributes of an open file generates a runtime error.

  • Setting file attributes clears any attributes that are not included in the attributes argument. For example, if somefile.txt is a read-only file, the statement:

         SetAttr("somefile.txt", vbArchive) 

    sets the archive attribute but clears the read-only attribute. To retain a file's attributes while setting new ones, first retrieve its attributes using the GetAttr function.

  • The FileAttribute.Directory enumeration member cannot be applied to a file or directory; it can only be set by the operating system.

Version Differences

Visual Basic 2005 includes My.Computer.FileSystem.GetDirectoryInfo and My.Computer.FileSystem.GetFileInfo methods that provide access to related functionality.

See Also

GetAttr Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net