遍历文件夹,操作XML文件,读取图片

前端之家收集整理的这篇文章主要介绍了遍历文件夹,操作XML文件,读取图片前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

//遍历文件
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);
}
}

//操作XML文件,读取图片

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

猜你在找的XML相关文章