views:

40

answers:

1

So I've been working on a system that includes multiple parts, such as a standard user-mode application, a plug-in for Internet Explorer, and a Windows Service. I need to be able to access and/or manipulate the same set of data files from all of these parts which may run under different user accounts. And I seem to be a little confused about the best place to store that data.

I am currently using a directory under the "All Users" profile. The only problem with this is that SHFileOperation does not seem to work to delete files from this directory when called from the Windows Service that runs under the Local System account; I get a file not found error. I realize that SHFileOperation is superseded by IFileOperation as of Vista, and I updated that code to use IFileOperation and it does indeed work here, but I'm wondering if I might run into other issues down the road.

So, the question is, is there a "better" place to store these data files on Win7 than under the "All Users" profile?

+2  A: 

ProgramData is the way to go. On my (pretty default) Windows 7 installation it maps to C:\ProgramData. It's not protected by UAC so nobody has to elevate to get to it. Make a folder in there with the name of your app and away you go. %ProgramData% will reach it from batch files etc, and you should be able to find it however you find known folders - CSIDL_COMMON_APPDATA if you're working in native code, System.Environment.SpecialFolders in managed code - if it's not in that enum then there's one in the Code Pack for it.

It can be a little hard for some users to find the file, if they like to look under My Documents, but then using the AllUsers profile might have that problem too.

Kate Gregory
FYI by default the All Users profile maps to C:\ProgramData, so it's the same as what I've been using. Perhaps I should have said the common appdata folder, as CSIDL_COMMON_APPDATA is what I have been using to get the path (maps to different places on different versions of Windows). In any case, it seems that it is the correct place to store the data, so I will just continue to use it and make sure I use IFileOperation on Win7 where appropriate.
Gerald