StorageItemTypes Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Describes whether an item that implements the IStorageItem interface is a file or a folder.
This enumeration supports a bitwise combination of its member values.
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
- Inheritance
-
StorageItemTypes
- Attributes
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Fields
File | 1 | A file that is represented as a StorageFile instance. |
Folder | 2 | A folder that is represented as a StorageFolder instance. |
None | 0 | A storage item that is neither a file nor a folder. |
Examples
The following example shows how to get the files and subfolders in the current folder by calling the GetItemsAsync() method. Then the example iterates over each IStorageItem and calls the IStorageItem.IsOfType method to determine whether each item is a file or a folder.
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);
}
Remarks
A value from this enumeration is returned by the IStorageItem.IsOfType, StorageFile.IsOfType, and StorageFolder.IsOfType methods.
The IsOfType method is useful for processing the results from a method that returns IStorageItem instances that can be files or folders. For example, the GetItemAsync and GetItemsAsync methods returns IStorageItem instances. To work with the returned items, call the IsOfType method of the IStorageItem interface to determine whether each item is a file or a folder. Then cast the item to a StorageFolder or StorageFile.