how to read all files inside particular folder
using System.IO;
...
foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
{
string contents = File.ReadAllText(file);
}
Note the above uses a .NET 4.0 feature; in previous versions replace EnumerateFiles
with GetFiles
). Also, replace File.ReadAllText
with your preferred way of reading xml files - perhaps XDocument
, XmlDocument
or an XmlReader
.
using System.IO;
//...
string[] files;
if (Directory.Exists(Path)) {
files = Directory.GetFiles(Path, @"*.xml", SearchOption.TopDirectoryOnly);
//...
using System.IO;
DirectoryInfo di = new DirectoryInfo(folder);
FileInfo[] files = di.GetFiles("*.xml");