Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All, I am using API to read several xml files (String file) in one time. Inside the XmlReader, I try to use the 2nd if-statement to break the reader and continue the foreach-loop to read through the next xml files. However, the following code will break the whole foreach-loop and only return to the 1st if-statement.
Can anyone advise how can I break the XmlReader and continue the foreach-loop to read through the rest xml files?
Thanks.
if (openFileDialog.ShowDialog() == DialogResult.OK) //1st if-statement
{
foreach (String file in openFileDialog.FileNames) //1st foreach-loop
{
string path = Path.GetFullPath(file);
using (var fileStream = File.OpenText(path))
using (XmlReader reader = XmlReader.Create(fileStream, settings))
{
//some code
if (......) //2nd if-statement
{break;}
//some code
}
//some code
}
}
Solved! Go to Solution.