Where to store windows program data files?

Have a look Environment.SpecialFolder Enum to decide about the right place for your data.

I would vote for Recent folder though, here are other options:

  • ApplicationData (Current users roaming profile)
  • CommonApplicationData (All users on local machine)
  • LocalApplicationData (Current user on local machine)

Get the folder of your choice with

Environment.GetFolderPath(Environment.SpecialFolder.xxx))

It is very dangerous to store user data in the application folder. Not only will the data be destroyed if the user updates or uninstalls your app, but Standard users cannot even write to the app directory.

I typically include a seed database in the application and copy it to a folder in the Environment.SpecialFolder.ApplicationData folder when the application launches. All user data is stored in the copy; if the user uninstalls the application the seed database is deleted but the user data remains. See this SO answer for an example.

Tags:

C#