//遍历文件夹
ArrayList fileBox = new ArrayList();
DirectoryInfo theFolder = new DirectoryInfo(filepath);
DirectoryInfo[] dirInfo = theFolder.GetDirectories(); //遍历文件夹
foreach (DirectoryInfo NextFolder in dirInfo)
{
FileInfo[] fileInfo = NextFolder.GetFiles();
foreach (FileInfo NextFile in fileInfo) //遍历文件
{
if(NextFile.Extension==".XML")
fileBox.Add(NextFile.Name);
}
}
DirectoryInfo theFolder = new DirectoryInfo(path);
FileInfo[] fileInfo = theFolder.GetFiles();
foreach (FileInfo NextFile in fileInfo) //遍历文件
{
if (NextFile.Extension == ".XML")
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(NextFile.FullName);
XmlNode xmlNode1 = xmlDoc.SelectSingleNode("/DataMessage/Body/VehPlate");
info.VehPlate = xmlNode1.InnerText;
} else if (NextFile.Name.Contains("CarPic.jpg")) { FileStream fs = new FileStream(NextFile.FullName,FileMode.Open,FileAccess.Read); info.VehImage1 = new Byte[fs.Length]; fs.Read(info.VehImage1,info.VehImage1.Length); fs.Close(); }
原文链接:https://www.f2er.com/xml/299752.html