Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xml.Load() from file path using Directory.GetFiles not working

Status
Not open for further replies.

jermine

Programmer
Jun 15, 2001
59
SG
Hello there,
I am having trouble loading the xml files i got from a particular path.

I got the idea from this particular code :
Code:
Dim xmlReport As New XmlDocument
For Each reportpath In IO.Directory.GetFiles(MapPath("report/"), "*.xml")
xmlReport.Load(reportpath)
("report/@name").Value)
Next

and i want to be able to convert it to C#.

The filenames of files found using Directory.GetFiles the are successfully displayed withLabel1.Text.
Code:
XmlDocument xmlReport ;
string reportPath = MapPath("Report/");
string[] reportFiles = Directory.GetFiles(reportPath, "*.xml");
foreach (string file in reportFiles) 
{
   Label1.Text += file + "<br>";
}

however with :
Code:
XmlDocument xmlReport ;
string reportPath = MapPath("Report/");
string[] reportFiles = Directory.GetFiles(reportPath, "*.xml");
foreach (string file in reportFiles) 
{
   Xml.Load(file);
}
i get an "no instance of an object".

I hope u .NET gurus out there can help me on this.

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top