Accessing AllUsersApplicationData at install time
I am preparing a custom action that copies a file to a specific location. Existing users of the application will already have the file in the SpecialDirectories.AllUsersApplicationData
location. So I want to check there first.
However, at install time, when I try and access this location, this resolves to
...\Microsoft Corporation\Windows Installer - Unicode\3.1.4001.5512
Is there a quick way to get to the AllUsersApplicationData location for the app I'm installing, instead of the开发者_StackOverflow中文版 installer?
You cannot use AllUsersApplicationData in this scenario, neither in the installer nor in your application. The installer cannot guess the version number correctly. Just make your own so that the installer can compute the path and get the right directory.
Use Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) and append your company and product name. And you probably want to append a version number. This version should be the version of the application data, not the application. Just make up your own, start at "1.0". The installer now has no trouble doing the same.
精彩评论