views:

47

answers:

2

I'm building a product that involves

  • a windows service caching data on the local machine,
  • user processes reading that data and writing their own data,
  • the service in turn writing back that data to a server.

Where should I put the data files for this, such that they'll be shared by all users and read/writable? The software will operate in a corporate environment where desktops are sometimes pretty locked-down, so for instance some users won't have write rights to C:\Program Files.

I don't think C:\Documents And Settings\All Users\Application Data\ is a good candidate - I think by default only Admins & Power Users have write access here.

I could use each user's Application Data folder, but this would be a bit of a pain as different people could use each machine ... so it'd be simpler if there was just one shared location.

I'm developing in C# .net 2005, but that's probably not too relevant.

+1  A: 

Unfortunately you have no real choice. You must (you really must) call SHGetSpecialFolderLocation to get the path to c:\users\public\AppData (which is the name of the folder you linked above, but on Vista and possibly Windows 7) Then you MUST create your own app folder therein. And then, you MUST, use the security APIs to modify the ACL of the created folder.

There is NO folder on the system with a default ACL that allows multiple non administrator users to read AND write the same files.

c:\users\public\AppData is the closest. Modifying the ACL of a application folder here seems the best approach. Of course, once one has resorted to ACL modification, the folder really could be created anywhere at all. But that could surprise system administrators and result in weired security holes.

Chris Becke
Do you think that it's reasonable to have a folder within c:\users\public\AppData with a modified ACL so all users can read/write, or will that also surprise sysadmins and/or conflict with automated policies? I guess it would be possible, but lots more work, to have separate caches per user stored in their user AppData folder, but I'd really like to avoid that if at all possible.
Rory
\users\public\AppData is the (only) folder where there is already a reasonable expectation that all users can read files. Hence my thought that this is the most reasonable place (least suprising :P) to add a folder that all users have write access too.
Chris Becke
A: 

The qustion I came here for was "How do I get the Users/Public folder? I'm using .net and there's a nifty Environment.SpecialFolder enum, but I tried them all (almost) and none return that folder.. Which is really strange.

The closest I've got is Environment.SpecialFolder.CommonApplicationData which gives "C:\ProgramData" on Windows7 and Vista, and "C:\Documents and Settings\All Users\Application Data" on Windows XP. I guess it'll have to do, but then I wonder wth Users/Publis is really for?

reallyjoel