Click or drag to resize
GDStorageFolderGetItemAsync Method
Gets the file or folder with the specified name from the current folder.

Namespace:  GD
Assembly:  GD (in GD.dll) Version: 255.255.255.255
Syntax
public IAsyncOperation<IGDStorageItem> GetItemAsync(
	string name
)

Parameters

name
Type: SystemString
The name (or path relative to the current folder) of the file or folder to get.

Return Value

Type: IAsyncOperationIGDStorageItem

When this method completes successfully, it returns an IGDStorageItem) that represents the specified file or folder.

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.

Implements

IGDStorageFolderGetItemAsync(String)
Exceptions
ExceptionCondition
Exception(C# equivalent: System.IO.FileNotFoundException) The specified item does not exist. Check the value of name.
AccessDeniedException(C# equivalent: System.UnauthorizedAccessException) Secure storage was remotely wiped.
InvalidArgumentException(C# equivalent: System.ArgumentException) The path contains invalid characters, or the format of the path is incorrect. Check the value of name.
Remarks

Call the IsOfType method of the IGDStorageItem interface to determine whether the returned item is a file or a folder.

To get a specific file without casting the return value, call the GetFileAsync(String) method. To get a specific folder without casting the return value, call the GetFolderAsync(String) method.

To try to get a file or folder by name, or to check whether a file or folder exists, without the need to handle a Exception, call the TryGetItemAsync(String) method.

Examples
The following example shows how to get a single file or folder from the current folder by calling the GetItemAsync(String) method. This example also shows how to get an item from a subfolder of the current folder by providing a relative path.
using GD;

// Get root folder of GD secure storage
GDStorageFolder rootFolder = GDWindows.Instance.SecureFolder;

// Create subfolder and a file
var subFolder = await rootFolder.CreateFolderAsync("Subfolder");
var file = await subFolder.CreateFileAsync("File.txt");

// Get the subfolder
var level1Folder = (GDStorageFolder)await rootFolder.GetItemAsync("Subfolder");

// Get the subfolder of the subfolder by providing a relative path.
var level2File = (GDStorageFile)await rootFolder.GetItemAsync(@"Subfolder\File.txt");
See Also