Where to store custom configuration files

Currently, I store the serialized XML file in the application directory, which contains all the changes specific to the program (not a typical system or user configuration). Weeks ago, we began to run into problems when it didn’t save correctly (read my previous question about this).

In short, we finally found that Windows 7 (and sometimes Vista) has problems writing to the application directory (in particular, anything in Program Files). Now, if it was a regular configuration file, I would just save it in the APPDATA user folder, but this is not normal. We run this on our own hardware, and incorrect configurations are 99% of the reasons why customers have problems running our software. Therefore, we need this file so that it is available so that it can easily find it and send an email to us. Appdata is difficult enough for experienced users to find, and even less so for technologists.

We also tried to run it as an Administrator and widely allowed access to folders (we have control over every computer on which it works, it will never be launched on any random machine). But sometimes they work, and sometimes they don’t.

The worst part is that when I write the file back, it does not even give an error; he simply writes it to some temporary directory, which expires at some unknown point in time. After a few weeks, our user will have a problem and the configuration file will be corrupted.

So my question is: where should I store this file, if not in Program Files? Should I just put it in APPDATA anyway and make a small utility that automatically sends it to us by email in case of a problem? Or can I leave it in Program Files, but change some specific permissions or registry key so that it can work fine?

+3
source share
2 answers

It depends on whether the user needs to edit the file directly. If not, you should put them in% APPDATA%, with which you can access via:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Otherwise, you can put it in My Documents:

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

, Program Files . , , .

+1

, . , .

, , , .

+1

Source: https://habr.com/ru/post/1755039/


All Articles