【问题标题】:Check if folder pointed by StorageFolder still exist检查 StorageFolder 指向的文件夹是否仍然存在
【发布时间】:2021-08-09 17:47:43
【问题描述】:

如何检查 StorageFolder 指向的文件夹是否仍然存在?

【问题讨论】:

    标签: c++ uwp windows-runtime


    【解决方案1】:

    假设您的应用具有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;
        }
    }
    

    【讨论】:

    • 嗯,这是我找到的最好的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-25
    相关资源
    最近更新 更多