/// <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;
        }

 

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-01-09
  • 2022-12-23
相关资源
相似解决方案