Jaa


FileAttributes Enum

Definition

Describes the attributes of a file or folder.

This enumeration supports a bitwise combination of its member values.

public enum class FileAttributes
/// [System.Flags]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class FileAttributes
[System.Flags]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum FileAttributes
var value = Windows.Storage.FileAttributes.normal
Public Enum FileAttributes
Inheritance
FileAttributes
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Fields

Name Value Description
Normal 0

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

ReadOnly 1

The item is read-only.

Directory 16

The item is a directory.

Archive 32

The item is archived.

Temporary 256

The item is a temporary file.

LocallyIncomplete 512

The item is locally incomplete. Windows only.

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.");

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.

Applies to