Net Core 下载图片

直接上代码

string url = https://www.cnblogs.com/images/logo_small.gif;
//获取网站当前根目录
string sWebRootFolder = hostingEnv.WebRootPath;
//保存图片路径
var savePath = string.Format("\Uploads\{0}\{1}\{2}\", DateTime.Now.Year, DateTime.Now.Month.ToString("D2"), DateTime.Now.Day.ToString("D2"));
//文件名
string filename = System.IO.Path.GetFileName(url);
//扩展名
string extension = System.IO.Path.GetExtension(url);
savePath = sWebRootFolder + savePath;
//无夹创建
if (!Directory.Exists(savePath))
{
  Directory.CreateDirectory(savePath);
}
WebClient mywebclient = new WebClient();
//下载文件
mywebclient.DownloadFile(url, savePath + filename);
原文地址:https://www.cnblogs.com/Akgu/p/9869714.html