Copy image file from web url to local folder?

后端 未结 4 1269
刺人心
刺人心 2021-02-02 18:01

I have a web URL for the image. For example \"http://testsite.com/web/abc.jpg\". I want copy that URL in my local folder in \"c:\\images\\\"; and also when I copy that file into

4条回答
  •  无人共我
    2021-02-02 18:58

    Request the image, and save it. For example:

    byte[] data;
    using (WebClient client = new WebClient()) {
      data = client.DownloadData("http://testsite.com/web/abc.jpg");
    }
    File.WriteAllBytes(@"c:\images\xyz.jpg", data);
    

提交回复
热议问题