xml图片的生成

来源: twotwotwo (个人网站)   日期:2006-08-13  我要评论  胶粘剂 结构胶 硅胶 密封胶 中国胶粘剂网
string xmlFileName=strTempXml; XmlTextWriter xw=new XmlTextWriter(xmlFileName,Encoding.UTF8); xw.WriteStartDocument(); xw.WriteStartElement("image"); xw.WriteString(photo); xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); xw.Close(); //写入x

string xmlFileName=strTempXml;
     XmlTextWriter xw=new XmlTextWriter(xmlFileName,Encoding.UTF8);
     xw.WriteStartDocument();
     xw.WriteStartElement("image");
     xw.WriteString(photo);
     xw.WriteEndElement();
     xw.WriteEndDocument();
     xw.Flush();
     xw.Close();
     //写入xml成功

     //从xml读入到图片
     XmlTextReader xr=new XmlTextReader(strTempXml);
     byte[] buffer = new byte[bufferSize];
     int readByte=0;
     //Create a file to write the bmp back.  jpgNewFile表示新图片
     this.jpgPackFile=this.jpgPackFile.Replace(".jpg",j+".jpg");
     FileStream fileNew = new FileStream(this.jpgPackFile, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
     BinaryWriter bw = new BinaryWriter(fileNew);
     xr.MoveToContent();   
     do
     {
      readByte=xr.ReadBase64(buffer, 0, bufferSize);
      bw.Write(buffer, 0, readByte);
     } while(readByte>=bufferSize);

     bw.Flush();    
     bw.Close();    
     fileNew.Close();
     xr.Close();//关闭 !!!!  

顶一下
(1)
100%
踩一下
(0)
0%
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码: