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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值