Export (0) Print
Expand All

FileSystemInfo.Attributes Property

Gets or sets the FileAttributes of the current FileSystemInfo.

[Visual Basic]
Public Property Attributes As FileAttributes
[C#]
public FileAttributes Attributes {get; set;}
[C++]
public: __property FileAttributes get_Attributes();
public: __property void set_Attributes(FileAttributes);
[JScript]
public function get Attributes() : FileAttributes;
public function set Attributes(FileAttributes);

Property Value

FileAttributes of the current FileSystemInfo.

Exceptions

Exception Type Condition
FileNotFoundException The specified file does not exist.
DirectoryNotFoundException The specified path is invalid, such as being on an unmapped drive.
SecurityException The caller does not have the required permission.
ArgumentException The caller attempts to set an invalid file attribute.
IOException Refresh cannot initialize the data.

Remarks

When first called, FileSystemInfo calls Refresh and returns the cached information on APIs to get attributes and so on. On subsequent calls, you must call Refresh to get the latest copy of the information.

The value of this property is a combination of the archive, compressed, directory, hidden, offline, read-only, system, and temporary file attribute flags.

The following table lists examples of other typical or related I/O tasks.

To do this... See the example in this topic...
Create a text file. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading Text from a File
Append text to a file. Opening and Appending to a Log File

File.AppendText

FileInfo.AppendText

Rename or move a file. File.Move

FileInfo.MoveTo

Get the attributes of a file. File.GetAttributes
Set the attributes of a file. File.SetAttributes
Read from a binary file. Reading and Writing to a Newly Created Data File
Write to a binary file. Reading and Writing to a Newly Created Data File

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

See Also

FileSystemInfo Class | FileSystemInfo Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File

Show:
© 2014 Microsoft