Where to save application data in .NET application

坚强是说给别人听的谎言 提交于 2020-02-21 11:13:23

问题


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?


回答1:


I ended up using the solution Patrick suggested:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)



回答2:


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.



来源:https://stackoverflow.com/questions/4650209/where-to-save-application-data-in-net-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!