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

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

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

11条回答
  •  庸人自扰
    2020-11-22 15:30

    Also you can use DownloadFileAsync method in WebClient class. It downloads to a local file the resource with the specified URI. Also this method does not block the calling thread.

    Sample:

        webClient.DownloadFileAsync(new Uri("http://www.example.com/file/test.jpg"), "test.jpg");
    

    For more information:

    http://csharpexamples.com/download-files-synchronous-asynchronous-url-c/

提交回复
热议问题