我应该在哪里存储我的应用程序的文件 [英] Where should I be storing my application's files

查看:77
本文介绍了我应该在哪里存储我的应用程序的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用会创建应该为用户保留的文件。

My app creates files that should be persisted for the user.

我宁愿不要求用户必须命名和保存文件,而是自动执行,因为文件可以从它们被获取的日期和时间以及它们中包含的一些内容来描述。

I'd rather not ask the user to have to name and save files, rather do it automatically, as the files can be described from the date and time they were acquired and some of the content contained in them.

目前,我将数据存储在ApplicationData.Current.LocalFolder中,但是我遇到了一些问题。

Currently, I'm storing the data in ApplicationData.Current.LocalFolder, but I'm having a couple of problems.

首先,数据似乎完全没有明显消失。 我不确定这是因为我做了重建,还是由其他原因引起的。

First, the data seems to disappear completely for no apparent reason.  I'm not sure if this is because I've done a rebuild, or if it's caused by something else.

其次,我想为用户提供以前打开的选项。文件 但是,存储我选择的文件似乎会使文件选择器无法访问这些文件。 我是否必须实现自己的UI来选择文件?

Second, I'd like to offer the user the option to open previous files.  However, storing files where I have chosen appears to make them inaccessible to the file picker.  Do I have to implement my own UI for selecting files?

第三,我注意到ApplicationData似乎有一个全局版本号,我不知道这应该如何应用于现有文件版本不匹配。 我可以开始转换,但是用户显然可以通过随时关闭应用来锁定转换
,所以我不确定如何保证不丢失数据。

Third, I notice ApplicationData seems to have a global version number, and I'm not sure how this should apply to existing files if the versions don't match.  I could begin the conversion, but the user could obviously pull the plug on the conversion by closing the app at any moment, so I'm not sure how I can guarantee not to lose the data.

是否有关于如何处理此文档的文档的指示,因为我找不到。

Are there any pointers to the documentation on how this should be handled, as I can't find any.

Anthony Wieser |维瑟软件有限公司|
www.wieser-software.com

Anthony Wieser | Wieser Software Ltd | www.wieser-software.com

推荐答案

1)卸载app时,系统会从LocalFolder中删除所有文件。在开发过程中,每次更改应用程序清单时,您的应用程序都会被卸载并再次安装 - 这就是文件消失的原因。
2)文件选择器无法访问LocalFolder。所以是的,如果你在那里存储文件 - 你需要自己的UI。

3)版本号对应用程序设置和应用程序数据更有用,而不是用户数据。如果您更改存储数据的方式,它允许从旧版本迁移设置和数据。



如果您认为应用程序存储的数据对用户有用即使没有您的应用程序或想要提供对数据文件的直接访问,您也可以考虑将文件存储在Documents文件夹中。至少它会解决你的问题#2。
1) System removes all files from LocalFolder when app is uninstalled. During development, every time you change app manifest your app is uninstalled and installed again – this is the reason why files are disappears.
2) LocalFolder is not accessible for File Picker. So yes, if you storing files there – you need own UI.
3) Version number is more useful for app settings and app data, not user data. It allows migrating settings and data from old version if the way you store the data is changed.

If you believe that the data stored by you app will be useful for user even without your app or want to provide direct access to the data file, than you can consider storing files in Documents folder. At least it will resolve your issue #2.


这篇关于我应该在哪里存储我的应用程序的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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