获取另一个项目中一个项目的user.config. [英] Get the user.config of one project in another project.

查看:59
本文介绍了获取另一个项目中一个项目的user.config.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
如何在另一个项目中检索一个项目的 user.config 文件,它们的exe名称相同但版本号不同.

说明:
创建一个标题为HappyDay的简单Windows应用程序
在名为背景"的设置"中存储一个变量,并在其中保存背景色.
单击按钮时在其上放置一个按钮,可通过访问Setting的背景变量来更改背景.


创建另一个项目并执行相同的步骤.

构建这些项目.
现在,将第二个项目exe重命名为与第一个项目相同.

我想在第二个项目执行时获得第一个项目的配置.
这可能吗?如果是,那么请详细说明如何实现.
谢谢

问候,
Itz.Irshad

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

推荐答案

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")


这篇关于获取另一个项目中一个项目的user.config.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆