简体   繁体   English

在通用Windows应用程序中访问本地应用程序数据

[英]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.

相关问题 Windows通用应用程序。 拒绝访问路径 - Windows universal application. Access to the path is denied 如何将现有的 SQLite 数据库放入应用程序的本地数据存储中,以便在通用 Windows 平台应用程序中使用? - How do you place an exisiting SQLite database into an application's local data store for use in a Universal Windows Platform application? 是否可以访问本地目录中的文件? (通用Windows平台) - is it possible to access files in local directories? (Universal Windows Platform) 如何使用通用Windows应用程序将串行数据写入COM端口? - How to write serial data to COM ports with Universal Windows Application? Applicaiton对象在WPF中的ViewModel中为null,试图访问Application变量 - Applicaiton object is coming null in ViewModel in wpf, trying to access Application variables 在Windows Universal Application中调整复选框的大小 - Resizing Checkboxes in Windows Universal Application 在Windows 7中通过\\ Local Settings \\ Application Data \\启动应用程序时出错 - Error when start application through \Local Settings\Application Data\ in Windows 7 如何在我的本地应用程序中启用远程访问 - IIS Windows 10 - How to enable remote access in my local application - IIS Windows 10 将击键发送到Windows中的Java应用程序 - Send keystrokes to Java applicaiton in Windows Windows 10(通用Windows应用程序)数据验证 - Windows 10 (Universal Windows App) data validation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM