Click here to Skip to main content
15,921,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiiii all I have image URL with me like below instead of binding that to image to screenshot I have to save that in any folder in project or any directory please help me..

What I have tried:

imgScreenShot.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes);
Posted
Updated 3-Apr-16 19:55pm
v3

Try this sample

C#
string folderPath = Server.MapPath("~/ImagesFolder/");  //Create a Folder in your Root directory on your solution.
string fileName = "IMageName.jpg";
string imagePath = folderPath + fileName;

string base64StringData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADmCAYAAAA..........."; // Your base 64 string data
string cleandata = base64StringData.Replace("data:image/png;base64,", "");
byte[] data = System.Convert.FromBase64String(cleandata);
MemoryStream ms = new MemoryStream(data);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
img.Save(imagePath, System.Drawing.Imaging.ImageFormat.Jpeg);
 
Share this answer
 
Comments
Member 12377320 4-Apr-16 2:09am    
thanks very much bro u are genius bro..
Karthik_Mahalingam 4-Apr-16 2:23am    
ha ha, welcome :)
Member 12377320 13-Apr-16 9:34am    
hi, bro.
can we convert one page into an image in asp.net without using system.windows.forms namespace?
Karthik_Mahalingam 13-Apr-16 10:44am    
google it bro, you will get lot of articles. and you can also post a question here. you will get different answers from experts.
i haven't tried like that so far.
Idika Destiny 12-Mar-21 8:13am    
Awesome bro.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900