StorageItemTypes 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
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.IsOfType 및 StorageFolder.IsOfType 메서드에서 반환됩니다.
IsOfType 메서드는 파일 또는 폴더일 수 있는 IStorageItem 인스턴스를 반환하는 메서드의 결과를 처리하는 데 유용합니다. 예를 들어 GetItemAsync 및 GetItemsAsync 메서드는 IStorageItem 인스턴스를 반환합니다. 반환된 항목을 사용하려면 IStorageItem 인터페이스의 IsOfType 메서드를 호출하여 각 항목이 파일인지 폴더인지 확인합니다. 그런 다음, 항목을 StorageFolder 또는 StorageFile으로 캐스팅합니다.
적용 대상
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기