Where to store Application Data and configuration files?

J

James

Hi all,

I am new to .NET programming. I am wring a project, say FOOBAR, it
contains
3 executable files, say p1.exe, p2.exe, p3.exe, which will be installed
to
C:\Program Files\FOOBAR

The programs need read from a configuration file, say config.txt.
Normal users
could edit this file manually via say NotePad. The programs also write
log files
to hard drive.

My question is where to store the configuration file and those log
files, e.g.
C:\Documents and Settings\All Users\Application Data\FOOBAR

Initially, I want to store the config.txt in C:\Program Files\FOOBAR,
but then
I realized that normal users do not have permissions to modify the
files at that
directory.

Is there any standard/document on where to store application data and
what
permissions should we give to files/dirs?

Many thanks,

James
 
J

James

Btw, when should we create the folder to store files?
During installation or program first running?

Thanks

James
 
G

Guest

Look at Environment.SpecialFolder...
and also at IsolatedStorage.

I believe Environment.SpecialFolder.ApplicationData will create itself (good
and bad since it uses the build number).

Good luck,
Eric
 
B

Ben Voigt

James said:
Hi all,

I am new to .NET programming. I am wring a project, say FOOBAR, it
contains
3 executable files, say p1.exe, p2.exe, p3.exe, which will be installed
to
C:\Program Files\FOOBAR

The programs need read from a configuration file, say config.txt.
Normal users
could edit this file manually via say NotePad. The programs also write
log files
to hard drive.

My question is where to store the configuration file and those log
files, e.g.
C:\Documents and Settings\All Users\Application Data\FOOBAR

Initially, I want to store the config.txt in C:\Program Files\FOOBAR,
but then
I realized that normal users do not have permissions to modify the
files at that
directory.

Best: put a machine-wide configuration file in the program directory.
Non-administrators would be installing in a directory you can write, admins
putting it in C:\Program Files\ may want to control the settings. Make one
of the settings the location to load/save user-specific settings. Expand
environment variables when you use it. Then admins can specify to get user
settings from %USERPROFILE%\stuff or z:\stuff\%USERNAME% or whatever.

This is similar the paradigm used by Unix (load from /etc/program.rc and
then ~/.programrc) and it is awfully flexible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top