Q:

How to use a App.config file in WPF applications?

I created a App.config file in my WPF application:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appsettings>
    <add key="xmlDataDirectory" value="c:\testdata"/>
  </appsettings>
</configuration>

Then I try to read the value out with this:
string xmlDataDirectory = ConfigurationSettings.AppSettings.Get("xmlDataDirectory");

But it says this is obsolete and that I should use ConfigurationManager which I can't find, even searching in the class view.
Does anyone know how to use config files like this in WPF?

A:

You have to reference the System.Configuration assembly that is in GAC.
Use of ConfigurationManager is not WPF-specific: it is the privileged way to access configuration information for any type of application.
Please see MSDN for further info
Hope it helps !
Cédric

A:

In my case I followed below steps
App.config
<configuration>  
   <startup> 
       <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>

 <appSettings>
   <add key="POCPublishSubscribeQueueName" value="FormatName:Direct=OS:localhost\Private$\POCPublishSubscribe"/>
 </appSettings>

</configuration>

Added System.Configuartion to my project
Added using System.Configuration statement in file at top
Then used below statement
string queuePath = ConfigurationManager.AppSettings["POCPublishSubscribeQueueName"].ToString();

A:

In your app.config, change your appsetting to
<applicationSettings>
    <WpfApplication1.Properties.Settings>
        <setting name="appsetting" serializeAs="String">
            <value>c:\testdata.xml</value>
        </setting>
    </WpfApplication1.Properties.Settings>
</applicationSettings>

Then, in the code-behind,
string xmlDataDirectory = WpfApplication1.Properties.Settings.Default.appsetting.ToString()

HTH

