.NET 应用程序中应用程序数据的保存位置

发布于 2024-10-11 10:30:12 字数 265 浏览 0 评论 0原文

我的应用程序类似于联系人管理器。假设用户可以输入联系人及其地址。我有代码和技术可以将我的联系人保存到文件中。但我该在哪里保存该文件呢?

考虑到这是一个在 Windows 上运行的 .NET 应用程序。我的文件应该存放在用户文件夹的 AppData 中吗?我应该使用独立存储(如此处所述)吗?还有别的事吗?推荐的做法是什么?

My application is something similar to a Contact Manager. Let's say a user can enter contacts with their addresses. I have the code and technology to save my contacts to a file. But where do I save that file?

Considering this is a .NET application running on Windows. Should my file end up in the AppData of the users folder? Should I use the Isolated Storage (as mentioned here)? Something else? What's the recommended practice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

治碍 2024-10-18 10:30:12

我最终使用了帕特里克建议的解决方案:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

I ended up using the solution Patrick suggested:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
冰雪梦之恋 2024-10-18 10:30:12

您有多种选择;正如你所说,独立存储就是其中之一。您还可以使用用户设置框架功能并将数据保存为数据 blob 或 XML。

您还可以查看 SqlCompact,它是一个非常轻量级的进程内数据库。然后,您可以将所有用户联系人保存在单个数据库中,该数据库可以与应用程序位于同一目录中;您可以轻松地将 EF4 之类的东西用于您的 DAL。

不过,这可能需要付出更多的努力,因为听起来您当前的架构已经完成了 99%。

You have a number of options; as you say, Isolated Storage is one of them. You could also use the User Settings framework feature and save the data as a blob of data, or as XML.

You could also take a look at SqlCompact for a very lightweight in-process database. You can then save all user contacts in a single database which could live e.g. in the same directory as the application; you could easily use something like EF4 for your DAL.

That might be a bit more effort though, as it sounds like you are 99% of the way there with your current architecture.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文