Summary (4) - Save Image to XML file
Squire: Terrylee
One. Save pictures to XML files
1
/ ** /
///
4
Private
Void
UploadImageToxml ()
5
{6 / ** //// give users to upload file 7 string strFilePathName = loFile.PostedFile.FileName; 8 string strFileName = Path.GetFileName (strFilePathName); 9 int FileLength = loFile.PostedFile.ContentLength; 10 if ( FileLength <= 0) 11 return; 12 try13 {14 / ** //// Image file temporary storage Byte array 15 byte [] filebyteaRray = new byte [fileLength]; 1617 / ** //// Establish data stream pair Like 18 Stream StreamObject = Lofile.postedFile.InputStream; 1920 / ** //// Read Image File Data, FileByteArray is a data storage body, 0 is a data pointer location, fileELnegth is the data length 21 streamObject.read (FilebyTearray, 0 , FileLength; 2223 / ** ///////> Document 24 string filename = server.mappath (".// Writexml.xml"); 25 26 xmlDocument xmldoc = new xmldocument (); 27 xmldoc.load (filename ); 2829 / ** /// / Find
xmlDoc.CreateElement ( "ImageDescription"); 51 xesub4.InnerText = tbDescription.Text; 52 xe1.AppendChild (xesub4); 53 XmlElement xesub5 = xmlDoc.CreateElement ( "ImageData"); 54 xesub5.InnerText = Convert.ToBase64String (FileByteArray) 55 XE1.Appendchild (Xesub5); 56 57 / ** /// Add to
1
/ ** /
///