Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从FutureAccessList同步获取文件夹路径_C++_.net_Uwp - Fatal编程技术网

C++ 从FutureAccessList同步获取文件夹路径

C++ 从FutureAccessList同步获取文件夹路径,c++,.net,uwp,C++,.net,Uwp,我使用FolderPicker在FutureAccessList中存储了许多文件夹。出于日志记录/配置的目的,我希望能够枚举它们,并将它们的完整路径作为字符串打印出来 我编写了下面的代码来尝试并帮助实现这一点,但它不断抛出以下内容: Unhandled exception at 0x0355CAB6 (ucrtbased.dll) in foo.exe: An invalid parameter was passed to a function that considers invalid p

我使用FolderPicker在FutureAccessList中存储了许多文件夹。出于日志记录/配置的目的,我希望能够枚举它们,并将它们的完整路径作为字符串打印出来

我编写了下面的代码来尝试并帮助实现这一点,但它不断抛出以下内容:

Unhandled exception at 0x0355CAB6 (ucrtbased.dll) in foo.exe: An invalid 
parameter was passed to a function that considers invalid parameters fatal.
这是代码,如果有人能告诉我哪里出了问题,我将不胜感激。实际上,我希望以同步方式执行GetFolderAsync函数,即exec wait return。我相信有一个简单的答案,但我只是在学习具有其他语言背景的C++/UWP编程

String^ MainPage::GetFolderPathForKey(String^ key)
{
    task<String^> t = create_task(
        StorageApplicationPermissions::FutureAccessList->GetFolderAsync(key))
        .then([](StorageFolder^ folder)
    {
        if (folder != nullptr) {
            return folder->Name;
        }
        return ref new String(L"Unknown?");

    });
    String^ taskResult = t.get();
    return taskResult;
}
String^MainPage::GetFolderPathForKey(字符串^key)
{
任务t=创建任务(
StorageApplicationPermissions::FutureAccessList->GetFolderAsync(键))
。然后([](StorageFolder^文件夹)
{
如果(文件夹!=nullptr){
返回文件夹->名称;
}
返回ref新字符串(L“未知?”);
});
字符串^taskResult=t.get();
返回任务结果;
}

问题是由于试图在UI线程中执行get()/wait()