GDStorageFolderGetItemsAsync Method |
Namespace: GD
public IAsyncOperation<IReadOnlyList<IGDStorageItem>> GetItemsAsync()
When this method completes successfully, it returns a list of the files and folders (type IVectorView) in the folder. Each file in the list is represented by a IGDStorageItem object.
To work with the returned item, call the IsOfType method of the IGDStorageItem interface to determine whether the item is a file or a folder. Then cast the item to a GDStorageFolder or GDStorageFile.
Exception | Condition |
---|---|
AccessDeniedException | (C# equivalent: System.UnauthorizedAccessException) Secure storage was remotely wiped. |
Call the IsOfType method of the IGDStorageItem interface to determine whether the returned item is a file or a folder.
This query is a shallow query that returns only items in the current folder.
To get only files, call the GetFilesAsync method. To get only folders, call the GetFoldersAsync method.
using GD; // Get the files and folders in the current folder. var items = await GDWindows.Instance.SecureFolder.GetItemsAsync(); // Iterate over the results and print the list of items to the Visual Studio Output window. foreach (IGDStorageItem item in items) { if(item.IsOfType(StorageItemTypes.Folder)) Debug.WriteLine("Folder: " + item.Name); else Debug.WriteLine("File: " + item.Name + ", " + item.DateCreated); }