注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发Asp → 文章内容

xml图片的生成

作者:IT 来源:不详 发布时间:2007-9-1 19:38:16

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();//关闭 !!!!  


http://www.itcnw.com/
  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体

热点文章

关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved