how to save image from web request in c#

Posted by Unknown
How to save image from web request in c#:


In this article am going to explain you how to save an image  from web request:
In order to implement this please have a look at bellow code:


 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(MyUrl);
            req .Timeout = 5000;
            req .ReadWriteTimeout = 19000;
            HttpWebResponse res = (HttpWebResponse)request.GetResponse();
            System.Drawing.Image img = System.Drawing.Image.FromStream(res.GetResponseStream());
            // Save the response to the output stream
  
            string path = "C:\\Myfolder\\sample.png";
            img.Save(path, System.Drawing.Imaging.ImageFormat.Png);

I hope this will helps you in dev
Labels: , ,

Post a Comment

 
test