//遍历文件夹
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, 0, info.VehImage1.Length);
fs.Close();
}