Windows Dev Center

FileAttributes enumeration

Describes the attributes of a file or folder.

Syntax


public enum FileAttributes

Attributes

[Flags()]
[Version(0x06020000)]

Members

The FileAttributes enumeration has these members.

MemberValueDescription
Normal | normal0

The item is normal. That is, the item doesn't have any of the other values in the enumeration.

ReadOnly | readOnly1

The item is read-only.

Directory | directory16

The item is a directory.

Archive | archive32

The item is archived.

Temporary | temporary256

The item is a temporary file.

LocallyIncomplete | locallyIncomplete512

The item is locally incomplete. Windows only.

Remarks

The FileAttributes enumeration is used with the StorageFile.Attributes and StorageFolder.Attributes properties.

The enumeration values match the Win32 file type attributes. Therefore the enumeration values correspond to the Win32 values, which are flags in base 2.

Examples

The following example shows how to check the attributes of a folder.


using Windows.Storage;
using System.Diagnostics; // For writing results to the Output window.
...
            // Get the app's installation folder.
            StorageFolder appFolder =
                Windows.ApplicationModel.Package.Current.InstalledLocation;

            // Get the folder's attributes.
            FileAttributes folderAttributes = appFolder.Attributes;

            // Check the folder's attributes.
            // Write the results to the Visual Studio Output window.
            if ((folderAttributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                Debug.WriteLine("The item is read-only.");
            if ((folderAttributes & FileAttributes.Directory) == FileAttributes.Directory)
                Debug.WriteLine("The item is a folder.");
            if ((folderAttributes & FileAttributes.Archive) == FileAttributes.Archive)
                Debug.WriteLine("The item is archived.");
            if ((folderAttributes & FileAttributes.Temporary) == FileAttributes.Temporary)
                Debug.WriteLine("The item is temporary.");



Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

 

 

Show:
© 2015 Microsoft