تبدیل عکس به رشته و بازگردانی آن ...

// Setup: Create a base64 string containing the image bytes

System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\pict1.jpg");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
string b64 = Convert.ToBase64String(ms.ToArray());
// Housecleaning: Get rid of the local instances
img.Dispose();
ms.Close();




// Here's where aikeith's relevance starts

byte[] b;
b = Convert.FromBase64String(b64);

ms = new System.IO.MemoryStream(b);
img = System.Drawing.Image.FromStream(ms);



// Since this is a console app, save file so I can see if it works.

img.Save(@"c:\pict1_from_b64.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

// Housecleaning: Get rid of the local instances
ms.Close();