Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to save application data in .NET application

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?

like image 717
Peter Avatar asked Jan 10 '11 18:01

Peter


2 Answers

I ended up using the solution Patrick suggested:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
like image 200
Peter Avatar answered Nov 04 '22 21:11

Peter


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.

like image 43
Isaac Abraham Avatar answered Nov 04 '22 21:11

Isaac Abraham