views:

249

answers:

3

Hi guys.

Until Windows Vista I was saving my application data into the directory where the program was located. The most common place was "C:\Program Files\MyApplication". As we know, under Vista and later the common user does't have rights to write under "Program Files" folder. So my first idea was to save the application data under "All Useres\Application Data" folder. But it seams that this folder has writing restrictions too!

So to sum up, my requirements are:

  • Folder should exist under Windows XP and above Microsoft's systems.
  • All useres of the system should read\write\creation rights to this folder and it subfolders and files.
  • I want to have only one copy of file\files for all useres.

Thanks for your time.

+1  A: 

It's often good to use environment variables so you keep things more generic.

Vista has changed some things, with NTFS Junction Points. See http://www.svrops.com/svrops/articles/jpoints.htm

Anyway, using %appdata% should automagically put files in the proper place on xp/vista/7

rkulla
%appdata% isn't a shared writable common area, is it?
RBarryYoung
I've meant each user of the Windows sytem.
Wodzu
+1  A: 

There is no such location. Even on Windows XP (and probably 2000 as well) no such location ever existed; we just think it did because we all ran with administrative privileges. It is not until Vista forces us to run as limited user that we realize our incorrect assumptions. You're going to have to explicitly set the permissions on your directory.

Luke
Thanks Luke, I guess I will setup privileges during the installation process under administrator account.
Wodzu
If there's no such location, then what's .NET's System.Windows.Forms.Application.CommonAppDataPath (typically resolves to C:\Documents and Settings\All Users\Application Data\CompanyName\ProductName\VersionNum)?
Conrad Albrecht
The default permissions for All Users\Application Data do not grant full access to limited user accounts. If an administrative user creates a file there, a limited user will not have write access to that file. It seems like the original question was trying to accomplish exactly this, so modifying the DACL is necessary.
Luke
A: 

I would create a subfolder like All Users\Application Data\YourAppName\Shared, so that it's clear that just that folder will contain files writeable by all the users, setting up the privileges in the installer.

Matteo Italia