得到应用WinRT的本地文件夹 [英] Get Local Folders from App WinRT

查看:134
本文介绍了得到应用WinRT的本地文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,尝试将文件保存到WinRT的应用程序,我在工作中的文件夹。更具体:我不能管理获取的文件夹。我需要保存一些文件然后再从同一个文件夹检索它们,让我们说 MyFolder中这实际上是在同级别中与应用程序的资产文件夹中。如何能够做到这样的事情?

I'm having an issue trying to save a file into a folder of the WinRT app I'm working at. More specific : I can't manage to retrieve the folder. I need to save some files and afterwards to retrieve them from that same folder, let's say MyFolder which is actually at the same level in the app with the Assets folder. How can I achieve such thing?

到目前为止,我试过

await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("MyFolder")

await ApplicationData.Current.LocalFolder.GetFolderAsync("MyFolder");

和似乎都告诉我,这样的文件夹不存在。现在,我似乎无法弄清楚,如果我在正确的轨道上,或它的东西,愚蠢的我已经做了,并会导致异常。我真的不能张贴整个代码,因为它实际上是与其他呼叫较大的方法的调用,等等。

and both seem to tell me that such folder doesn't exist. Now, I can't seem to figure it out if I'm on the right track or it's something foolish I've done and causes that exception. I can't really post the whole code, because it's actually a call to a larger method with other calls, and so on.

另外,我想知道(如果有的话这些方法都是正确的),如果应用程序得到更新,内容以任何方式的影响(还好说,丢失)。

Also, I'd like to know (if any of these methods are correct), if the app gets an update, the content is affected in any way (better said, lost).

感谢您。

推荐答案

Windows.ApplicationModel.Package.Current.InstalledLocation 会给你应用程序包中定义的文件系统,所以你会看到你常用的资源文件夹,例如,通过URI MS-APPX:///资产通过任何或InstalledLocation在 MS-APPX 计划访问是只读的,因为它是由你从Visual Studio部署项目中定义。

Windows.ApplicationModel.Package.Current.InstalledLocation will give you the 'file system' defined by the application package, so you'd see you the commonly used Asset folder, for instance, via the URI ms-appx:///Assets Anything accessed via InstalledLocation or the ms-appx scheme is read-only because it's defined by the project you deployed from Visual Studio.

ApplicationData.Current.LocalFolder 允许您访问文件系统通过目前的应用/用户所拥有的(并存储在%APPDATA%/本地/包装/< yourapppackage> / LocalState )。你可以创建任何你想要的结构在这里管理你的各种角色,并使用 MS-应用程序数据:///本地/ DirLeve1 / DirLeve2 / FILE3 URI来访问您的文件) 。该存储是通过更新保存到你的应用程序,不过,当然,你需要更新任何需要存储的数据格式与应用程序的新版本进行交互的策略。

ApplicationData.Current.LocalFolder allows you to access the 'file system' owned by the current application/user (and stored at %AppData%/Local/Packages/<yourapppackage>/LocalState). You can create whatever structure you want here to manage your various roles, and use the ms-appdata:///local/DirLeve1/DirLeve2/File3 URI to access your files). That storage is retained through updates to your application, though, of course, you'll need a strategy for updating whatever stored data formats are required to interact with the newer version of your application.

这听起来像你假设LocalFolder不能包含一个文件夹hiearachy;它可以,所以你可以有比如LocalFolder参考下最近通话子文件夹,处理事情的方式。

It sounds like you're assuming LocalFolder cannot contain a folder hiearachy; it can, and so you could have a Recents subfolder for instance under the LocalFolder reference and handle things that way.

这篇关于得到应用WinRT的本地文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆