I am working on XML files. I have created small XML tool which returns number of specific tag repeated in all files.
This code runs properly to find the numbers of tag present in files within specific folder mean there should not be any other folder in XML files containing folder.
I am facing problem if there is any other folder or other type of file present in the XML files containing folder this programs fails.
The code is as follow:
public void SearchMultipleTags()
if (txtSearchTag.Text != "")
string folderPath = textBox2.Text;
DirectoryInfo di = new DirectoryInfo(folderPath);
FileInfo rgFiles = di.GetFiles("*.xml");
foreach (FileInfo fi in rgFiles)
int i = 0;
XmlDocument xmldoc = new XmlDocument();
foreach (XmlNode node in xmldoc.GetElementsByTagName(txtSearchTag.Text))
i = i + 1;
rtbox2.Text += DateTime.Now + "\n" + fi.FullName + " \nInstance: " + i.ToString() + "\n\n";
MessageBox.Show("Invalid Path or Empty File name field.");
MessageBox.Show("Dont leave field blanks.");
Please help in this.
Edited 7-Oct-12 5:22am
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)