Miquel
Miquel

Reputation: 15675

Where should my application/service store its configuration files in windows?

In Linux, I'll usually put user configuration files in $HOME/.myapp and in Windows I'll use APPDATA. So far so good.

What about non-user specific configuration? In linux, I'd put it into /etc. Is there an equivalent in Windows? Please note I would like to have the service running before any user logs in. Also, in case it plays a role, I'm developing in Java.

Alternatively: I approaching this the wrong way?

Upvotes: 1

Views: 1142

Answers (3)

Jack Ukleja
Jack Ukleja

Reputation: 13501

In summary, you should use the known folder: ProgramData.

To avoid hard coding of paths (and hence why I'm not providing them here) you should always retrieve the value via one of the following methods:

This folder is not writeable by non-admins, so depending on your requirements you'll want to create a directory for your program and set the ACLs you need at install time.

Some good information on this topic is provided in the blog post: "Where Should I Write Program Data Instead of Program Files".

For those interested in using other Known Folders, MSDN provides extensive documentation.

Upvotes: 2

Jason Crosby
Jason Crosby

Reputation: 3573

In Windows most "program files" for an app go in C:\Program Files\MyApp. The environment variable would be %ProgramFiles%\MyApp.

Upvotes: 1

Steve
Steve

Reputation: 216273

You could use ALLUSERPROFILES as a base directory. This environment variable resolves to the C:\PROGRAMDATA folder in Windows7. Of course you need to add a specific folder for your applications

Upvotes: 2

Related Questions