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