Actually the question has already been asked. Here is the code for the download itself.

using (var request = new HttpRequest()) { HttpResponse response = request.Get(link); response.ToFile("file"); } 

But how to display progress on the ProgressBar?

  • Can I ask you a question? Why xNet? This is not a library, but a collection of bicycles - almost everything is implemented by .Net itself and done much better. - Sergey

1 answer 1

Well, there seems to be a DownloadProgressChanged event - you should subscribe to it and that's it. Type

  request.DownloadProgressChanged += (value) => {progressBar1.Value = value;} 
  • If I want to hang a method, then how to do it? Something of the type: request.DownloadProgressChanged += DownloadProgressBar(); ? But how can I in the method find out the download status from DownloadProgressChangedEventArgs e ? - Max
  • If we are talking about this xNet github.com/X-rus/xNet, then OnDownloadProgressChanged += DownloadProgressBar , where `DownloadProgressBar (DownloadProgressChangedEventArgs e) {/ * Processor * /}. The main thing that the signature with the delegate of the event coincided. - Sergey