StorageItemTypes 열거형

정의

IStorageItem 인터페이스를 구현하는 항목이 파일인지 폴더인지를 설명합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class StorageItemTypes
/// [System.Flags]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class StorageItemTypes
[System.Flags]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum StorageItemTypes
var value = Windows.Storage.StorageItemTypes.none
Public Enum StorageItemTypes
상속
StorageItemTypes
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

필드

File 1

StorageFile instance 표시되는 파일입니다.

Folder 2

StorageFolder instance 표시되는 폴더입니다.

None 0

파일이나 폴더가 아닌 스토리지 항목입니다.

예제

다음 예제에서는 GetItemsAsync() 메서드를 호출하여 현재 폴더의 파일 및 하위 폴더를 가져오는 방법을 보여 줍니다. 그런 다음, 각 IStorageItem 을 반복하고 IStorageItem.IsOfType 메서드를 호출하여 각 항목이 파일인지 폴더인지 확인합니다.

using Windows.Storage;
using System.Threading.Tasks;
using System.Diagnostics; // For writing results to Output window.

// Get the app's installation folder.
StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;

// Get the files and folders in the current folder.
IReadOnlyList<IStorageItem> itemsInFolder = await appFolder.GetItemsAsync();

// Iterate over the results and print the list of items
// to the Visual Studio Output window.
foreach (IStorageItem item in itemsInFolder)
{
    if(item.IsOfType(StorageItemTypes.Folder))
        Debug.WriteLine("Folder: " + item.Name);
    else
        Debug.WriteLine("File: " + item.Name + ", " + item.DateCreated);
}

설명

이 열거형의 값은 IStorageItem.IsOfType, StorageFile.IsOfTypeStorageFolder.IsOfType 메서드에서 반환됩니다.

IsOfType 메서드는 파일 또는 폴더일 수 있는 IStorageItem 인스턴스를 반환하는 메서드의 결과를 처리하는 데 유용합니다. 예를 들어 GetItemAsyncGetItemsAsync 메서드는 IStorageItem 인스턴스를 반환합니다. 반환된 항목을 사용하려면 IStorageItem 인터페이스의 IsOfType 메서드를 호출하여 각 항목이 파일인지 폴더인지 확인합니다. 그런 다음, 항목을 StorageFolder 또는 StorageFile으로 캐스팅합니다.

적용 대상