Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys,
How can we retrieve user.config file of one project in another project have same name of exe but different version number.

Description:
Create a simple windows application with title HappyDay
Store a variable in Settings named as Background and save a background color in it.
Place a button on it when button is clicked the background is changed by accessing Setting's background variable.


Create another project and do same step.

Build those projects.
Now rename the 2nd project exe with name same as 1st Project.

I want to get the configuration of 1st project on 2nd project execution.
Is this possible? If yes, then please detailed me how can it be achieved.
Thanks

Regards,
Itz.Irshad
Posted
Comments
Sergey Alexandrovich Kryukov 16-Apr-12 11:50am    
Why is that a problem? Do you have a source code of both projects? Or do you need to do it during run time, on a permanent basis? Why?
You need first explain the ultimate goal of this activity, if you really need and advice.
--SA

1 solution

XML
very easy, I've made 2 projects as you write.
and I've made ​​an app.config file in the project, like this:

<? xml version = "1.0" encoding = "utf-8"?>
<configuration>

   <! - ....... ->
   <! - ....... ->

   <connectionStrings>
     <add name="TEST" connectionString="Application 2"/>
   </ ConnectionStrings>
   <appSettings>
     <add key="App setting" value="Application 2"/>
   </ appSettings>

</ configuration>


as you can see, I gave two settings.
The first is the connectionString and appSetting
connectionString used to store the configuration database, you may be able to use the appSetting

change the file name as the name of your application, for example MyApplication.exe.config, before the name was changed app.config

The following configuration code to get inside MyApplication.exe.config

Configuration.ConfigurationManager.ConnectionStrings ("TEST"). ConnectionString
or
Configuration.ConfigurationManager.AppSettings ("App settings")
 
Share this answer
 
Comments
Itz.Irshad 17-Apr-12 0:50am    
Let's make it simple.

I'm going to deploy new version of an application. In essence, it's totally new project but identical to previous application with some new features.
So, My user save his/her preferences in previous application and I store them in user.config file in Local Setings of that user. (As VS do usually)

Now, I'm try to retrieve those settings in my new application. This is to facilitate the user to not mention the preferences again. His/Her previous preferences will be retain in new version.

Note: Application exe have same name as previous application exe.

Now, please guide me how to do that.

Thanks

Itz.Irshad
Hendra Yudha P 17-Apr-12 3:18am    
Your application should be a folder with user.config, in order to retrieve the configuration

should be no problem if you create two projects are the same and one user.config, with project A or B to access user.config

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900