I am working in C#.Net. I am having a XML File. From that i will get the data and then i process it. Bydefault that XML will be in a folder and i will use that. Here is my code..
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Test.xml"));
--My Process Starts Here.....
In the same folder i will have multiple XML Files.(ie) Test.XML,Test1.XML,Test2.XML etc... I want to process all the XML Files. Each and every time i cant able to change the file name in my source code. I thought of passing the file name itself as a parameter. I want to know whether this is correct. Or else any other way to do this.
I tried with this..Now i can able to access all the XML Files.
XmlDocument xDoc = new XmlDocument();
string path = Directory.GetCurrentDirectory();
foreach (string file in Directory.EnumerateFiles(path, "*.xml"))
{
xDoc.Load(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), file));
string strpath = xDoc.BaseURI;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.