I have a class library project and in that project I have both xml file and class in which read data from that file.
So what code should write for it.
Thanks
Sandeep
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 23, 2012, 9:43 AM
As the current directory may not be where you think it is, I'd use the full path to the file in the XElement.Load method rather than just config.xml if that's what you're doing at present.
Sandeep Singh ShekhawatPosted Oct 22, 2012, 9:45 PM
I am getting error when xml file load.
Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\config.xml'.
So Where do I create this file ? Currently I have it in Root directory.
Thanks
Sandeep
VulpesPosted Oct 22, 2012, 5:19 AM
For example, using LINQ to XML:
Santhosh Kumar JayaramanPosted Oct 22, 2012, 5:00 AM
then u can say
string str= ConfigurationManager.ConnectionStrings["con"].ToString();
and con is my connection string name
Check my article to know about more
http://www.c-sharpcorner.com/UploadFile/1a81c5/configuring-connection-string-in-app-config-file-during-runt/
Sandeep Singh ShekhawatPosted Oct 22, 2012, 4:56 AM
And I want connection string in string variable from this. these are in class library.
Santhosh Kumar JayaramanPosted Oct 22, 2012, 3:19 AM
if you want to convert xml to dataset
string path = "D:\\Santhosh\\XMLFile1.xml";
DataSet ds=new DataSet();
//Reading XML file and copying to dataset
ds.ReadXml(path);
If you want to convert xml to list of strings.