最近一直在纠结软件中用户配置信息以及数据库存放位置问题,winxp系统以前不存在UAC重定向问题,但是自从Win7系统以后就发现没有管理员权限时,安装在系统盘中的软件配置信息若需要读写操作时,系统会自动将这些配置文件和数据库重定向到当前用户的AppData\Local\VirtualStore目录中,虽然避免了系统报错问题,但是对于软件调试以及用户配置文件的修改造成了困扰。
以下是微软官方给出的AppData的定义(虽然显示的为win8系统,但是个人认为对win7和win10都通用):
Applies to Windows 8.1, Windows RT 8.1
The AppData folder contains app settings, files, and data specific to the apps on your PC. The folder is hidden by default in File Explorer, and has three hidden sub-folders: Local, LocalLow, and Roaming.
- Roaming. This folder (%appdata%) contains data that can move with your user profile from PC to PC—like when you’re on a domain—because this data has the ability to sync with a server. For example, if you sign in to a different PC on a domain, your web browser favorites or bookmarks will be available.
- Local. This folder (%localappdata%) contains data that can't move with your user profile. This data is typically specific to a PC or too large to sync with a server. For example, web browsers usually store their temporary files here.
- LocalLow. This folder (%appdata%/…/locallow) contains data that can't move, but also has a lower level of access. For example, if you're running a web browser in a protected or safe mode, the app will only be able access data from the LocalLow folder.
The apps themselves choose whether to save to the Local, LocalLow, or Roaming folders. Most desktop apps use the Roaming folder by default, while most Windows Store apps use the Local folder by default.
Warning
- We don't recommend moving, deleting, or making any changes to files or folders in the AppData folder. Doing so could make your apps run poorly or stop working entirely.
大部分桌面app程序都使用AppData\Roaming文件夹作为用户配置文件的存储位置,但是用户数据库若也存储在这个地方对于用户来说很不方便,文件夹为隐藏文件夹且不容易查找。我的解决方法是用户配置以及数据库文件默认路径为Romation文件夹,但是数据库文件夹路径是开放给用户的,用户可以自定义数据库存放位置,这样方便以后用户数据的备份以及恢复。