Save pictures into an XML file WinForm resource file, convert the non-text content such as PictureBox's image property into text, which is implemented by serialization, example: // using system.Runtime.Serialization. Formatters.Soap; Stream stream = new FileStream ( "E: //Image.xml", FileMode.Create, FileAccess.Write, FileShare.None); SoapFormatter f = new SoapFormatter (); Image img = Image.FromFile ( "E : //IMage.bmp "); F.Serialize (stream, img); stream.close (); The following example is encoded by UUENCODE (base 64 encoding) by the binary flow and saves it in the file, illustrating Tobase64String Usage of methods. Public void encodewithstring () {system.io.filestream infile; byte [] binarydata
try {inFile = new System.IO.FileStream (inputFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read); binaryData = new Byte [inFile.Length]; long bytesRead = inFile.Read (binaryData, 0 , (Int) infile.Length); infile.close ();} catch (system.exception exp) {// error creating stream or reading from it. System.console.writeline ("{0}", Exp.Message) Return;}
// Convert the binary input into Base64 UUEncoded output string base64String;. Try {base64String = System.Convert.ToBase64String (binaryData, 0, binaryData.Length);} catch (System.ArgumentNullException) {System.Console.WriteLine ( "Binary data Array is Null. "); Return;}