How to use httpwebrequest to pull image from website to local file

前端 未结 4 1717
粉色の甜心
粉色の甜心 2020-11-27 07:29

I\'m trying to use a local c# app to pull some images off a website to files on my local machine. I\'m using the code listed below. I\'ve tried both ASCII encoding and UTF

4条回答
  •  温柔的废话
    2020-11-27 08:12

    You can use the following method to download an image from a web site and save it, using the Image class:

    WebRequest req = WebRequest.Create(imageUrl);
    WebResponse resp = req.GetResponse();
    Image img = Image.FromStream(resp.GetResponseStream());
    img.Save(filePath +  fileName + ".jpg");
    

提交回复
热议问题