输入图片网址,就可以保存远程图片

解决方案 »

  1.   

    用这个就可以了。。
    WebClient wc=new WebClient();
    wc.DownloadFile(src,FileName);
      

  2.   

    WebClient wc=new WebClient();
    wc.DownloadFile(src,FileName);
    src:远程图片的地址
    FileName:在本地保存的文件名System.Net类库下
    string remoteUri = "http://www.contoso.com/library/homepage/images/";
    string fileName = "ms-banner.gif", myStringWebResource = null;
    // Create a new WebClient instance.
    WebClient myWebClient = new WebClient();
    // Concatenate the domain with the Web resource filename.
    myStringWebResource = remoteUri + fileName;
    Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
    // Download the Web resource and save it into the current filesystem folder.
    myWebClient.DownloadFile(myStringWebResource,fileName);        
    Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
    Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);