【发布时间】:2021-08-09 17:47:43
【问题描述】:
如何检查 StorageFolder 指向的文件夹是否仍然存在?
【问题讨论】:
标签: c++ uwp windows-runtime
如何检查 StorageFolder 指向的文件夹是否仍然存在?
【问题讨论】:
标签: c++ uwp windows-runtime
假设您的应用具有appropriate permissions,您可以使用StorageFolder.GetFolderFromPathAsync API。
以下示例代码是用 C# 编写的,但应该会让您有所了解:
public static async Task<bool> ExistsAsync(StorageFolder folder)
{
try
{
await StorageFolder.GetFolderFromPathAsync(folder.Path);
return true;
}
catch (FileNotFoundException)
{
return false;
}
}
【讨论】: