Click to See Complete Forum and Search --> : Recommended location for local config files for an app


purpleflash
July 5th, 2009, 07:04 AM
Where should my app store local configuration files (like xml files) to retain screen position, etc.?

I just moved my development box from XP to Vista and apparently writing files to some folder inside "c:\program files" is verboten.

So where is the (now) recommended place to store these files?

thanks.

Using .Net 3.5 SP1 and WPF

Shuja Ali
July 5th, 2009, 07:19 AM
That seems to be an issue with the permissions on your system. Usually the config files will be retained in the same folder as your project. Don't you have write permissions on the folder where your project is located?

eclipsed4utoo
July 5th, 2009, 07:24 AM
a number of applications (Microsoft apps and Google apps) use the C:\Documents and Settings\[user]\Local Settings\Application Data". The "Local Settings" folder is a hidden folder, I believe, so it's a good place to put config files.

memeloo
July 5th, 2009, 10:22 AM
yet another solution: IsolatedStorage
http://www.codeguru.com/csharp/csharp/cs_data/article.php/c4225

purpleflash
July 5th, 2009, 10:25 AM
Is there a C# function to get a filepath to this folder (since it can't be known until installation). And if so, how does it work during development/debugging since the app isn't installed in its final location at that point? (this is for the C:\Documents and Settings\[user]\Local Settings\Application Data method)

memeloo
July 5th, 2009, 10:33 AM
maybe this will help
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

purpleflash
July 6th, 2009, 08:25 AM
What happens during debugging... where will that location be since the app isn't installed yet. thanks.

memeloo
July 6th, 2009, 08:33 AM
it's "hidden" here
C:\Users\USER\AppData\Local\BASE_NAMESPACE_NAME

**edit: I've forgotten to add that this is the path on Vista

purpleflash
July 6th, 2009, 08:40 AM
Ok. I think I will go this route.

Next question- I have two .xml files I need to store there, however I need to allow the users to copy their own custom .xml files to this location. Is it possible (within ClickOnce deployment) to copy skeleton versions of these .xml files to the app's local folder, but have the install leave these files alone if they are already there (customized by the user)?