Question

Possible Duplicate:
VS2008 Setup Project: Shared (By All Users) Application Data Files?

Please can someone advice what is the best place (path) to put some application data which should be accessible and editable by all users.

This is considering both Windows XP and Windows Vista and i expect that change in any file of above path does NOT trigger UAC!

OTHER TIPS

Plain Win API: SHGetFolderPath with CSIDL_COMMON_APPDATA as folder type.

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

Should resolve to C:\Documents and Settings\All Users\Application Data\

From there, make subfolders such as MyCompany\MyApp

If you're using .NET, Application.CommonAppDataPath should work. Also make sure that virtualization is turned off for your application

%ALLUSERSPROFILE%\Application Data\App
this is probably the only directory that all users can access without elevated privileges.

If you're using .NET, Application.CommonAppDataPath should work.

If the users are not going to modify the data directly, and it will only be modified by the app, how about IsolatedStorage - http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx

Checkers provides the vital clue to do this in C or C++. So I have voted his answer.

Here are the details he left out:

// assumes
// company is a pointer to a character sting containing company name
// appname is a pointer to a character string containing application name
// fname   is a pointer to a character string cintaining name of file to be created

#include <shlobj.h>   // for SHGetFolderPath
#include <direct.h>   // for _mkdir

char path[MAX_PATH];
SHGetFolderPath(NULL,CSIDL_COMMON_APPDATA,NULL,NULL,path);
strcat(path,"/");
strcat(path,company);
_mkdir(path);
strcat(path,"/");
strcat(path,appname);
_mkdir(path);
strcat(path,"/");
strcat(path,fname);

// path is now a character string which can passed to fopen

You can also put it in a database.

For Vista and higher, MS seems to be pushing for using SHGetKnownFolderPath() instead of SHGetFolderPath(). Choose what folder to ask for from the list of KNOWNFOLDERIDs. Based on the answers here, the equivalent you'd want would probably be FOLDERID_ProgramData. I realize this question is quite old, but I guess for archival purposes..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top