本文整理匯總了C#中Windows.Storage.StorageFolder.GetItemAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# StorageFolder.GetItemAsync方法的具體用法?C# StorageFolder.GetItemAsync怎麽用?C# StorageFolder.GetItemAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.Storage.StorageFolder
的用法示例。
在下文中一共展示了StorageFolder.GetItemAsync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: IfFolderExistsAsync
/// <summary>
/// It checks if the specified folder exists.
/// </summary>
/// <param name="storageFolder">The container folder</param>
/// <param name="subFolderName">The sub folder name</param>
/// <returns></returns>
private static async Task<bool> IfFolderExistsAsync(StorageFolder storageFolder, string subFolderName) {
try {
IStorageItem item = await storageFolder.GetItemAsync(subFolderName);
return (item != null);
}
catch {
// Should never get here
return false;
}
}
示例2: deleteFile
private void deleteFile(StorageFolder store, string f) //or Folder
{
try {
if (f.Length == 0 || (f.Length == 1 && f[0] == '\\'))
return; //root folder
var item = store.GetItemAsync(f).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
item.DeleteAsync().AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
}
catch (System.Exception err) {
//ignore file deletion errors
err.ToJavaException().printStackTrace();
}
}