none
Download file automatically from a website RRS feed

All replies

  • I have to say I'm getting more and more annoyed by people who come here FIRST instead of taking the time to search for answers on their own.  Had you done so, you would no doubt have found the System.Net.Http.HttpClient class, which does exactly what you want.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, March 20, 2020 7:09 PM
  • Also check this relatively simple method:

       var c = new WebClient( );

       string data = c.DownloadString( "https://api-adresse.data.gouv.fr/search/?q=8+bd+du+port" );

    Then use some JSON parser to extract the values from data or transform to objects.


    • Edited by Viorel_MVP Saturday, March 21, 2020 10:08 AM
    Saturday, March 21, 2020 10:07 AM
  • Hi jaweher89,
    You can also use WebClient.DownloadFileAsync method to download the specified resource to a local file as an asynchronous operation. And this method do not block the calling thread.
    Here is a simple code example you can refer to.

    using System.Net;
     // ...
     WebClient webClient = new WebClient();
     webClient.DownloadFileAsync(new Uri("url"), FilePath);

    Here is a related thread you can refer to.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 23, 2020 3:33 AM