Sam Mettenmeyer

Sam Mettenmeyer

  • 1.9k
  • 108
  • 8.6k

Update a WinForms-Application automatically (async)

Apr 19 2021 8:33 AM
Hello friends :)
 
I am trying to write a little application and, as I am only a student, i was wondering if someone maybe could help me with with some advices / tips to achieve the following:
 
On start, the desired program shall call a special function. That function looks onto a remote server (most likely it will be a NAS - network attached storage - with given username + password) if there is an update available. If yes, download & install it (including a display of the current progress) and restart program afterwards.
 
Having done some research, I found the following code snippet, hope it helps:
  1. var webClient = new WebClient();  
  2. webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);  
  3. webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);  
  4. webClient.DownloadFileAsync("https://195.50.139.130:5001/FTP/KlingGastro Update/file.txt""C:\\file.txt"); 
Please note: there is a blank character between KlingGastro and Update.
 
Furthermore the credentials are "KlingGastro" as username, please excuse that I will not post password due to security reasons. Lets say its "myPassword".
 
I think downloading is not going to be that big problem, I already found this tutorial:
 
https://ourcodeworld.com/articles/read/227/how-to-download-a-webfile-with-csharp-and-show-download-progress-synchronously-and-asynchronously
 
Rather the cancellation of the program by itself and the restart might could be difficult?
 
Sorry for all potential language faults in addition, hope it was nevertheless somehow understandable.
 
Would be really happy for every answer and help effort.
 
Best regards

Answers (1)