本文整理汇总了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();
}
}