Copy image file from web url to local folder?

后端 未结 4 1261
刺人心
刺人心 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:43

    string path = "~/image/"; 
    string picture = "Your picture name with extention";
    path = Path.Combine(Server.MapPath(path), picture);
    using (WebClient wc = new WebClient())
                                {
    wc.DownloadFile("http://testsite.com/web/abc.jpg", path);
                                }
    

    Its works for me

提交回复
热议问题