Shahbaz Kaware

Shahbaz Kaware

  • NA
  • 535
  • 31.3k

How to convert base64 string into image in wcf service

Nov 13 2019 12:55 AM
string _base64ImgString = objGenRequest.searchVal6.Replace("data: image", "").Replace("\"", "").Split(' ')[0].Replace("data:image/png;base64,", "");
 
Bitmap UploadImage = new Bitmap();
string path = HostingEnvironment.MapPath("~/Upload Images/Hello.jpg");
using (MemoryStream memory = new MemoryStream())
{
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
{
UploadImage.Save(memory, ImageFormat.Png);
byte[] bytes = memory.ToArray();
_base64ImgString = Convert.ToBase64String(bytes);
fs.Write(bytes, 0, bytes.Length);
}
}
 
 
Please help me im new to wcf 

Answers (5)