Accessing the user.config file on a newly installed application from the installer itself
-
Dear all. I want to access the user.config file from the installer itself, the problem is that I don't know how to get the path of the newly installed application. I know that the user.config file for my main application is somewhere in "'user'\AppData\Local\.... but I don't know how to access this area from the installer itself. In my main application it is very simple, I just call:
Configuration _usrConfigLoc = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Inside the installer I have tried:
Configuration _usrConfigLoc = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
This returns the path of the config file of the installer (and not my main application) Does anybody have a way to find the freshly installed user.config file from the installer application?
-
Dear all. I want to access the user.config file from the installer itself, the problem is that I don't know how to get the path of the newly installed application. I know that the user.config file for my main application is somewhere in "'user'\AppData\Local\.... but I don't know how to access this area from the installer itself. In my main application it is very simple, I just call:
Configuration _usrConfigLoc = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Inside the installer I have tried:
Configuration _usrConfigLoc = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
This returns the path of the config file of the installer (and not my main application) Does anybody have a way to find the freshly installed user.config file from the installer application?
protected override void OnAfterInstall(System.Collections.IDictionary savedState) { string t\_path = this.Context.Parameters\["assemblypath"\].ToString(); Configuration \_usrConfigLoc = System.Configuration.ConfigurationManager.OpenExeConfiguration(Path.Combine(t\_path,"user.config")); //... base.OnAfterInstall(savedState); }
-
protected override void OnAfterInstall(System.Collections.IDictionary savedState) { string t\_path = this.Context.Parameters\["assemblypath"\].ToString(); Configuration \_usrConfigLoc = System.Configuration.ConfigurationManager.OpenExeConfiguration(Path.Combine(t\_path,"user.config")); //... base.OnAfterInstall(savedState); }
Thanks for the quick reply, however this doesn't work exactly as I want to.... When running this code I get the C:\Program Files\..... folder and the corresponding .config file. However I want to access the .config file which lies in: "Users\user\AppData\Local\CompanyName\AssName++++\VersionNo\user.config" Any ideas?
-
Thanks for the quick reply, however this doesn't work exactly as I want to.... When running this code I get the C:\Program Files\..... folder and the corresponding .config file. However I want to access the .config file which lies in: "Users\user\AppData\Local\CompanyName\AssName++++\VersionNo\user.config" Any ideas?
-
Application.UserAppDataPath
It'll return like follow: "C:\\Documents and Settings\\mis-hongwenshi\\Application Data\\ccc\\WindowsApplication11\\1.0.0.0"
Thanks again for the very quick replies, however my problem is that I want to find the main application path and not the installer path. If I call Application.UserAppDataPath inside the installer it gives me: C:\Users\Kåre Tragethon\AppData\Roaming\Microsoft Corporation\Windows Installer - Unicode\5.0.7600.16385 I want to be able to find the main application path: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\0.8.4.9 Let me know if anything is not clear and I will try to explain some more.....
-
Thanks again for the very quick replies, however my problem is that I want to find the main application path and not the installer path. If I call Application.UserAppDataPath inside the installer it gives me: C:\Users\Kåre Tragethon\AppData\Roaming\Microsoft Corporation\Windows Installer - Unicode\5.0.7600.16385 I want to be able to find the main application path: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\0.8.4.9 Let me know if anything is not clear and I will try to explain some more.....
-
How about this
AppDomain.CurrentDomain.BaseDirectory
I think you deploy the project use the clickonce,am I right?
Thanks again for the very quick replies, and for helping me out and sorry for my bad English and explanations. No I don't use clickonce. I will do some more explaining: I have a main project (main application) which can be installed on any computer. This application contains user settings (user.config) which lies in the following directory: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\0.8.4.9 This is the standard location of user settings file, however when the main application changes version a new folder is created, e.g.: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\10.8.4.9 I also have an installer application in my project (the standard VS built-in installer). When I un-install the application I want to access the user.config file and get all the settings from this file (and I will save all the settings in the TEMP directory) so that when I install the application again I am able to retrieve all the settings (access the user.config file and write all the previously saved settings). Most often the reason for uninstall->install is that I have made a new version of the software and therefor I cannot rely on a static path to the user.config file, I will have to get it programmaticly.
-
Thanks again for the very quick replies, and for helping me out and sorry for my bad English and explanations. No I don't use clickonce. I will do some more explaining: I have a main project (main application) which can be installed on any computer. This application contains user settings (user.config) which lies in the following directory: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\0.8.4.9 This is the standard location of user settings file, however when the main application changes version a new folder is created, e.g.: C:\Users\Kåre Tragethon\AppData\Local\Tragethon_Teknikk\EasyNetTools.exe_Url_mxn53vo4iinbepot2fslrsybsd0vtoiz\10.8.4.9 I also have an installer application in my project (the standard VS built-in installer). When I un-install the application I want to access the user.config file and get all the settings from this file (and I will save all the settings in the TEMP directory) so that when I install the application again I am able to retrieve all the settings (access the user.config file and write all the previously saved settings). Most often the reason for uninstall->install is that I have made a new version of the software and therefor I cannot rely on a static path to the user.config file, I will have to get it programmaticly.
-
Anyone else?