[英]Access local application data in a Universal Windows Applicaiton
I'm trying to port the following to a UWP app: 我正在尝试将以下内容移植到UWP应用程序:
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string spotlightPath = System.IO.Path.Combine(localAppData, "Packages\\\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\\\LocalState\\\\Assets");
It look like ApplicationData.LocalFolder is exactly what I need: "Gets the root folder in the local app data store." 看起来ApplicationData.LocalFolder正是我所需要的:“获取本地应用程序数据存储区中的根文件夹。”
(from https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.aspx ) (来自https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.storage.applicationdata.aspx )
I can't work out how to access it though: var localAppData = ApplicationData.LocalFolder;
我不知道如何访问它:
var localAppData = ApplicationData.LocalFolder;
Gives the following error: An object reference is required for the non-static field, method, or property 'ApplicationData.LocalFolder' 出现以下错误:非静态字段,方法或属性'ApplicationData.LocalFolder'需要对象引用
使用它来访问您的应用程序的本地文件夹:
var localFolder = ApplicationData.Current.LocalSettings;
If you wish to get the path for for the app's settings and files: 如果您希望获取应用程序设置和文件的路径:
Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
string ThePath = localFolder.Path;
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/apps/hh700361(v=win.10) https://docs.microsoft.com/zh-cn/previous-versions/windows/desktop/apps/hh700361(v=win.10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.