/// <summary> /// 根据文件url,下载文件到本地 /// </summary> /// <param name="fileUrl">文件地址</param> /// <param name="path">保存路径</param> public static string DownFile(string fileUrl,string path) { if (!Directory.Exists(path)) Directory.CreateDirectory(path); var fileName = fileUrl.Substring(fileUrl.LastIndexOf("/") + 1); var filePath = path + "/" + fileName; WebClient wc = new WebClient(); if (!File.Exists(filePath)) wc.DownloadFile(fileUrl, filePath); else { filePath = path + "/" +Guid.NewGuid().ToString() + fileName; wc.DownloadFile(fileUrl, filePath); } return filePath; }