FileAttributes Перечисление

Определение

Описывает атрибуты файла или папки.

Это перечисление поддерживает побитовую комбинацию значений его членов.

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
Наследование
FileAttributes
Атрибуты

Требования к Windows

Семейство устройств
Windows 10 (появилось в 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (появилось в v1.0)

Поля

Archive 32

Элемент архивируется.

Directory 16

Элемент является каталогом.

LocallyIncomplete 512

Элемент является локально неполным. Только Windows.

Normal 0

Элемент является нормальным. То есть элемент не имеет других значений в перечислении.

ReadOnly 1

Элемент доступен только для чтения.

Temporary 256

Элемент является временным файлом.

Примеры

В следующем примере показано, как проверка атрибуты папки.

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

Комментарии

Перечисление FileAttributes используется со свойствами StorageFile.Attributes и StorageFolder.Attributes .

Значения перечисления соответствуют атрибутам типа файла Win32. Поэтому значения перечисления соответствуют значениям Win32, которые являются флагами в базе 2.

Применяется к