Tuesday, April 22, 2014

How to save an image using the image URL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO.MemoryStream;
using System.Drawing.Imaging;
using System.Net;
using System.IO.FileStream;
public partial class Default11 : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
        string urlToDownload = "http://www.google.co.in/images/srpr/nav_logo14.png";
        // May be you need to add some code to determine the type of the image
        string pathToSave = Server.MapPath("~/") + "/saved.png";
        // Download it
        WebClient client = new WebClient();
        client.DownloadFile(urlToDownload, pathToSave);
    }
)

0 comments:

Post a Comment