C++ 检查StorageFolder指向的文件夹是否仍然存在
如何检查由StorageFolder指向的文件夹是否仍然存在?假设您的应用程序具有,您可以使用C++ 检查StorageFolder指向的文件夹是否仍然存在,c++,uwp,windows-runtime,C++,Uwp,Windows Runtime,如何检查由StorageFolder指向的文件夹是否仍然存在?假设您的应用程序具有,您可以使用StorageFolder.GetFolderFromPathAsyncAPI 下面的示例代码是C语言的,但应该能让您了解这一点: public static async Task<bool> ExistsAsync(StorageFolder folder) { try { await StorageFolder.GetFolderFromPathAsync
StorageFolder.GetFolderFromPathAsync
API
下面的示例代码是C语言的,但应该能让您了解这一点:
public static async Task<bool> ExistsAsync(StorageFolder folder)
{
try
{
await StorageFolder.GetFolderFromPathAsync(folder.Path);
return true;
}
catch (FileNotFoundException)
{
return false;
}
}
公共静态异步任务ExistsAsync(存储文件夹)
{
尝试
{
等待StorageFolder.GetFolderFromPathAsync(folder.Path);
返回true;
}
捕获(FileNotFoundException)
{
返回false;
}
}
这是我找到的最好的解决方案。