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

一曲冷凌霜 提交于 2019-12-12 13:14:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3492070/what-is-a-good-place-to-store-data-files-on-win7-that-can-be-accessed-and-manipu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!