如何让我的应用程序在两个app.config文件之间进行选择?

Pri*_*nes 1 c# configuration app-config

我想创建两个app.config文件,让用户通过命令行参数决定使用哪个文件.如何让我的应用程序在我的代码中使用一个.config或另一个?

我正在使用由配置文件设置的设置文件.有两种可能的配置,如果用户可以只输入"> myprogram -live"或"> myprogram -test"并且程序选择要加载的配置文件,则会更容易.谢谢!

dee*_*hao 5

使用不同的名称复制两个exe文件:

myprogram.live.exe
myprogram.live.config
myprogram.test.exe
myprogram.test.config
Run Code Online (Sandbox Code Playgroud)

然后你可以选择开始myprogram.livemyprogram.test.