views:

908

answers:

1

Hi all,

I've started to become a Good Citizen, as per this question here:

http://stackoverflow.com/questions/1066782/domain-compatibility-where-should-shared-data-be-written

My user information is now written to the environment variable:

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

and then appending a directory there. If the directory does not exist, then the program automatically creates it, and then all cross-user information (log files, captured data, setup options, etc) are all stored in that file. My understanding of that file is that it should be entirely user writable, regardless of the setup of the machine.

On windows XP when attached to a domain, there's no problem; this file is detected and written to properly. On windows 7, the program doesn't work. The user's directory is now C:\ProgramData\MyFolder, and that folder is created as read only (genius! Why not make it just read only, after all, no one wants to write to the CommonApplicationData location!).

What directory should I be using? That 'special folder' is the one dedicated to the task that I need, but it appears that that folder isn't user writeable.

Edit in response to the first response: I'm using a WiX installer, and am completely fine with adding whatever file to the installer there. I'm not sure how to go about doing that, so please answer with the WiX installer magic words.

+2  A: 

According to Vista compatibility guidelines, your application should create a folder for its stuff under CommonApplicationsData in the installer (did I mention that it must also have an installer?), and assign appropriate permissions to that folder there.

Pavel Minaev
ok, so how do I use the FileSystemAccessRule for all users? The function call appears to only take a particular user id.
mmr
That user ID can be "Everyone", which is a group to which any Windows user belongs. You shouldn't hardcode the name, though, as it varies on localized Windows versions. Instead, use something like this: SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); FileSystemAccessRule rule = new FileSystemAccessRule(everyone, ...);
Pavel Minaev