您可以在 UWP 中使用来自库 (PicturesLibrary) 的 URI 吗?
Can You Use URI's from a Library (PicturesLibrary) In UWP?
我正在尝试使用此代码从 PicturesLibrary 访问文件的 URI:
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
StorageFile tpkFile = await picturesFolder.GetFileAsync("campus.tpk");
Uri tpkFileUri = new Uri(tpkFile.Path);
Debug.WriteLine("This is the tpkFile path: " + tpkFileUri);
ArcGISTiledLayer tpkLayer = new ArcGISTiledLayer(tpkFileUri);
try
{
MyMapView.Map.OperationalLayers.Add(tpkLayer);
}
catch(Exception e)
{
Debug.WriteLine("This is the Exception: " + e);
}
哪个 returns URI 为:
file:///C:/Users/username/Pictures/campus.tpk
但我知道 UWP 应用只接受以 ms-appx:///
开头的 URI
我的问题是,我如何才能访问带有 ms-appx:/// 前缀的第一个 URI 中的文件?
现在代码在这一行失败:
ArcGISTiledLayer tpkLayer = new ArcGISTiledLayer(tpkFileUri);
因为它说 URI 不正确,所以对 tpkLayer 的引用为空。
将其复制到您的 ApplicationData.Current 并使用 ms-appdata:/// 这样对您有用吗? ms-appx:/// 引用您的 appx 中的只读文件。
您可以在此处阅读有关 ms-appdata 架构的更多信息:https://blogs.windows.com/buildingapps/2014/06/19/common-questions-and-answers-about-files-and-app-data-part-1-app-data/#j4m8ylp93K7ujk6Q.97
我正在尝试使用此代码从 PicturesLibrary 访问文件的 URI:
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
StorageFile tpkFile = await picturesFolder.GetFileAsync("campus.tpk");
Uri tpkFileUri = new Uri(tpkFile.Path);
Debug.WriteLine("This is the tpkFile path: " + tpkFileUri);
ArcGISTiledLayer tpkLayer = new ArcGISTiledLayer(tpkFileUri);
try
{
MyMapView.Map.OperationalLayers.Add(tpkLayer);
}
catch(Exception e)
{
Debug.WriteLine("This is the Exception: " + e);
}
哪个 returns URI 为:
file:///C:/Users/username/Pictures/campus.tpk
但我知道 UWP 应用只接受以 ms-appx:///
我的问题是,我如何才能访问带有 ms-appx:/// 前缀的第一个 URI 中的文件?
现在代码在这一行失败:
ArcGISTiledLayer tpkLayer = new ArcGISTiledLayer(tpkFileUri);
因为它说 URI 不正确,所以对 tpkLayer 的引用为空。
将其复制到您的 ApplicationData.Current 并使用 ms-appdata:/// 这样对您有用吗? ms-appx:/// 引用您的 appx 中的只读文件。
您可以在此处阅读有关 ms-appdata 架构的更多信息:https://blogs.windows.com/buildingapps/2014/06/19/common-questions-and-answers-about-files-and-app-data-part-1-app-data/#j4m8ylp93K7ujk6Q.97