【问题标题】:what is absolute path in C++/WinRT什么是 C++/WinRT 中的绝对路径
【发布时间】:2021-07-19 16:04:29
【问题描述】:

错误:WinRT 发起错误-0x80070057:'指定路径(msappx:\Local\C:\Windows\Web\Screen\img103.png)不是绝对路径,不允许使用相对路径。 '

当我使用 C++/WinRT 时,函数调用是 winrt::Windows::Foundation::IAsyncOperationwinrt::Windows::Storage::StorageFile temp = StorageFile::GetFileFromPathAsync(hFilname);

我能做什么?

【问题讨论】:

  • 您的问题解决了吗?如果没有,请随时与我们联系。

标签: console visual-studio-2017 c++-winrt


【解决方案1】:

StorageFile.GetFileFromPathAsync()方法,你没有权限访问指定文件,请看here

我的建议是,你可以把图片文件存放在应用可以访问的应用安装目录中,然后使用下面的代码来访问。

StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;          
string path= Path.Combine(folder.Path, @"Data\img1.png");  
StorageFile.GetFileFromPathAsync(path); 

注意应用安装目录是..ProjectPath\bin\x86\Debug\Appx

【讨论】:

    猜你喜欢
    • 2020-11-16
    • 1970-01-01
    • 2014-10-30
    • 2011-06-15
    • 2018-04-02
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多