“User's Application Data Folder”; Is it possible to force between SpecialFolder.ApplicationData and SpecialFolder.LocalApplicationData

拈花ヽ惹草 提交于 2019-12-13 06:39:35

问题


I have an application that needs to run at normal privileges. So it gets installed in Environment.SpecialFolder.ProgramFiles, but stores conf/logging/history details in Environment.SpecialFolder.LocalApplicationData.

The problem is that in the Setup/Deploy project, in the File System section I don't get to distinguish between ApplicationData (roaming) or LocalApplicationData, only "User's Application Data Folder," which could be either depending who installs it on what machine.

Is it possible to force "User's Application Data" to be one or the other?


回答1:


MSI does support local application data folder. If you're talking about a Setup and Deployment project, maybe switching to another installer framework like WiX might be in order. (Setup and Deployment no longer exists in Visual Studio 2012 anyway). WiX has a tool called Dark that will convert an MSI to WiX XML files so you can simply edit them or add to them quickly and easily.




回答2:


The Setup Project has made a comeback in visual Studio 2015. The following works with VS 2015:

  • In file system view, add a special folder of type 'Custom'.
  • In the properties of this folder, set the following values:
    • Name : Local App data folder
    • AlwaysCreate : True
    • Condition : (leave empty)
    • DefaultLocation : [LocalAppDataFolder]
    • Property : SOMEPROPERTYNAME

The magic happen thanks to DefaultLocation property value: [LocalAppDataFolder].
I suppose any system folder variable as defined in the following link should work: https://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx#system_folder_properties



来源:https://stackoverflow.com/questions/12265498/users-application-data-folder-is-it-possible-to-force-between-specialfolder

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