0

I have this

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="FBI" type="System.Configuration.NameValueSectionHandler" />
  </configSections>
  <FBI>
    <add key="FilePath" value="D:\C Drive\Desktop\test1.txt"/>
  </FBI>
<configuration>

in app.config..

And I set the Copy to Output Directory for app.config to copy if newer.

In the program,

   var section = ConfigurationManager.GetSection("FBI") as NameValueCollection;
            FilePath.Text = section["FilePath"];

where FilePath is a label.

When I change the config file to

D:\C Drive\Desktop\test2.txt

and build using VS (release mode), it shows correctly as

D:\C Drive\Desktop\test2.txt

But if I change the app.config in release folder to

D:\C Drive\Desktop\test3.txt

and run using the exe file in the release folder directly, it still shows me

D:\C Drive\Desktop\test1.txt

without updating to test3.txt

What's the reason?

4

1 回答 1

2

如果更新,我将 app.config 的复制设置为输出目录以进行复制。

您不需要这样做:它将自动复制到AppName.exe.config输出文件夹中。您需要修改的是这个文件。

于 2012-09-26T13:54:16.063 回答