Gerald
Gerald

Reputation: 23479

What is a good place to store data files on Win7 that can be accessed and manipulated by multiple user accounts?

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?

Upvotes: 3

Views: 565

Answers (1)

Kate Gregory
Kate Gregory

Reputation: 18954

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.

Upvotes: 2

Related Questions