ipjyo
asked on
How to read appSettings section from App.Config?
hi,
I have the below App.Config file in my project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Xml" value="C:\Files\ins.xml"/>
</appSettings>
</configuration>
I am trying to get the value of key "Xml" as follows.
string xmlFile = "";
xmlFile = ConfigurationSettings.AppS ettings["X ml"];
But it is not showing the value when I tried to show the value in a messagebox.
I also imported the namespace "System.Collections.Specia lized" still not working.
Any ideas please?
I have the below App.Config file in my project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Xml" value="C:\Files\ins.xml"/>
</appSettings>
</configuration>
I am trying to get the value of key "Xml" as follows.
string xmlFile = "";
xmlFile = ConfigurationSettings.AppS
But it is not showing the value when I tried to show the value in a messagebox.
I also imported the namespace "System.Collections.Specia
Any ideas please?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The target framework is 3.5 if that makes any difference.
Thanks
Thanks
Change the as below and try.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="XmlFileName" value="C:\Files\ins.xml"/>
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="XmlFileName" value="C:\Files\ins.xml"/>
</appSettings>
</configuration>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This section was already there and generated automatically.
<?xml version="1.0" encoding="utf-8" ?>
Thanks.
<?xml version="1.0" encoding="utf-8" ?>
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried
Properties.Settings.Defaul t.Xml
but it is saying "The name 'Properties' does not exist in the current context". Also when I tried to type the above line, visual studio is not giving intellisense for the above line. I think I need to add some reference.
Thanks
Properties.Settings.Defaul
but it is saying "The name 'Properties' does not exist in the current context". Also when I tried to type the above line, visual studio is not giving intellisense for the above line. I think I need to add some reference.
Thanks
ASKER
It is working when I created a new project and tried the code.
It must have been something with some other code in my project.
sorry for the trouble.
It must have been something with some other code in my project.
sorry for the trouble.
ASKER
and then I tried the below statement and still not working. It is not giving any error message.
System.Configuration.Confi
Thanks.