How to download a file from a URL in C#?

前端 未结 11 1094
清歌不尽
清歌不尽 2020-11-22 15:13

What is a simple way of downloading a file from a URL path?

11条回答
  •  有刺的猬
    2020-11-22 15:32

    Try using this:

    private void downloadFile(string url)
    {
         string file = System.IO.Path.GetFileName(url);
         WebClient cln = new WebClient();
         cln.DownloadFile(url, file);
    }
    

提交回复
热议问题