william007
william007

Reputation: 18525

regarding app.config

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?

Upvotes: 0

Views: 186

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124686

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

You don't need to do this: it will be copied automatically to AppName.exe.config in the output folder. And it's this file you need to modify.

Upvotes: 2

Related Questions