C+中的std::filesystem::directory_迭代器+/CX UWP应用程序可以';找不到目录?
我正在编写一个跨平台的应用程序,所以我想用C++/CX resp在XAML中实现UI。可可,核心是标准C++。但是,我在访问文档时遇到问题 我提供了一个C+中的std::filesystem::directory_迭代器+/CX UWP应用程序可以';找不到目录?,uwp,visual-studio-2017,uwp-xaml,c++-cx,std-filesystem,Uwp,Visual Studio 2017,Uwp Xaml,C++ Cx,Std Filesystem,我正在编写一个跨平台的应用程序,所以我想用C++/CX resp在XAML中实现UI。可可,核心是标准C++。但是,我在访问文档时遇到问题 我提供了一个FolderPicker并获取路径并将其粘贴到目录迭代器中,但目录迭代器找不到任何文件,如果我在路径上调用exists(),它会显示false 我在谷歌上搜索过很多东西,但网上的一切都告诉我,一旦我有了StorageFolder,我就应该可以访问这些文件,而没有任何内容涉及到标准的C++17 API 我必须做什么才能让标准库访问这些文件 我使用以
FolderPicker
并获取路径并将其粘贴到目录迭代器中,但目录迭代器找不到任何文件,如果我在路径上调用exists()
,它会显示false
我在谷歌上搜索过很多东西,但网上的一切都告诉我,一旦我有了StorageFolder,我就应该可以访问这些文件,而没有任何内容涉及到标准的C++17 API
我必须做什么才能让标准库访问这些文件
我使用以下命令启动文件选择器:
FolderPicker ^picker = ref new FolderPicker;
picker->FileTypeFilter->Append( "*" );
IAsyncOperation<StorageFolder ^> ^storageFolderOp = picker->PickSingleFolderAsync();
auto asyncTask = concurrency::create_task(storageFolderOp);
asyncTask.then([this](StorageFolder ^storageFolder)
{
cout << "Picked directory: " << StdStringFromString(storageFolder->Path) << endl;
commandsPathField->Text = storageFolder->Path;
});
还有我的舱单:
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Identity
Name="69b58249-31af-4bb3-95f4-fd339268a557"
Publisher="CN=Uli"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="69b58249-31af-4bb3-95f4-fd339268a557" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>VanguardBotGUI</DisplayName>
<PublisherDisplayName>Uli Kusterer</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="vanguardbot_win.App">
<uap:VisualElements
DisplayName="vanguardbot_win"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="vanguardbot_win"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<rescap:Capability Name="appDiagnostics" />
</Capabilities>
</Package>
先锋博图
乌利·库斯特雷
资产\StoreLogo.png
如果您想运行它并单步执行(只需为UI设置用户名/密码,失败就在该点之前)。相关文件有windows/MainPage.xaml.cpp
(vanguardbot\u win::MainPage::FolderPicker\u Click
)、common/vanguardbot.cpp
(vanguardbot::connect
)和vanguardbot/windows/Package.appxmanifest
。解决方案是顶级的vanguardbot_win.sln
。不幸的是,从FolderPicker
返回的文件夹是一个“代理”位置,这意味着对它的所有访问都是通过执行适当安全检查的进程外组件进行的。WinRT存储API知道如何处理这些代理位置,但标准CRT/STL函数不知道(此时)。为了正确处理代理位置,需要更新这些库,以便在后台调用较新的Win32 API
目前,您必须使用Windows.Storage
API,或者直接使用Win32 API,例如可以处理代理位置的API。您能否提供一个示例?我已经添加了相关的代码并添加了指向完整项目的链接,我希望这是一个开始?该项目现在基本上是标准的UWP空窗口应用程序模板,因为在失败之前我从未接触过其他代码。这是在STL github上提出的,并且决定这不是STL错误(下面的url)。因此,看起来我们被UWP api困住了,它目前工作得非常糟糕。
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Identity
Name="69b58249-31af-4bb3-95f4-fd339268a557"
Publisher="CN=Uli"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="69b58249-31af-4bb3-95f4-fd339268a557" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>VanguardBotGUI</DisplayName>
<PublisherDisplayName>Uli Kusterer</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="vanguardbot_win.App">
<uap:VisualElements
DisplayName="vanguardbot_win"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="vanguardbot_win"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<rescap:Capability Name="appDiagnostics" />
</Capabilities>
</Package>