Basic Programming
Basic Programming
  • 1
  • 38 961
How to make an automatic updater in Visual Studio! | C# | 2020 | With and without Setup!
In this video I'm going to show you how to make an easy automatic updater for your program. It's connected to the web.
The code I used:
Main program:
using System.Net;
using System.Diagnostics;
InitializeComponent();
WebClient webClient = new WebClient();
try
{
if (!webClient.DownloadString("yourpastebinlink").Contains("1.5.0"))
{
if (MessageBox.Show("Looks like there is an update! Do you want to download it?", "Demo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
using (var client = new WebClient())
{
Process.Start("UpdaterDemo.exe");
this.Close();
}
}
}
catch
{
}
-----------------------------------
Updater:
using System.Net;
using System.IO;
using System.Diagnostics;
using System.IO.Compression;
InitializeComponent();
WebClient webClient = new WebClient();
var client = new WebClient();
try
{
System.Threading.Thread.Sleep(5000);
File.Delete(@".\Demo.exe");
client.DownloadFile("yourhostinglink", @"Demo.zip");
string zipPath = @".\Demo.zip";
string extractPath = @".\";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\Demo.zip");
Process.Start(@".\Demo.exe");
this.Close();
}
catch
{
Process.Start("Demo.exe");
this.Close();
}
zhlédnutí: 38 964

Video

Komentáře

  • @Crisb-gi3sm
    @Crisb-gi3sm Před 9 měsíci

    Could you pass me the project? For some reason it won't let me use the references.

  • @rfsvieira2733
    @rfsvieira2733 Před rokem

    tks After 3 yrs do you have code for HttpClient()? tks

  • @niyomja
    @niyomja Před rokem

    In Demo program update by hardcode check version if not contains 1.5.0 then start updaterdemo.exe. after that updaterDemo.exe try delete demo.exe is current running it can not delete. can do exit demo program and run updater it work properties. Thanks.

  • @eyalgerber
    @eyalgerber Před rokem

    Very useful video! Thanks a lot!

  • @killua8397
    @killua8397 Před rokem

    thank you the setup works fine and the download action of the new version works perfekt BUT the project load again and again the old version the new version get the old version all my changes are not updatet but how can it be i can see how the zipfile down.loaded into programms 86 und i can see how my old exe dbe deletet and replace with the new exe but after the update my project looks excact how the old version i cannot figure out how it does it please help

  • @ilovewomen2976
    @ilovewomen2976 Před 2 lety

    can someone post the solution?

  • @typeblvck.7918
    @typeblvck.7918 Před 2 lety

    For Everyone Who is Having Trouble I have managed to make it alot simpler and it works. So first if you use 000webhosting there is no need for .zip or .rar just upload the .exe file in public.html inside a folder. this will make the code alot simpler and faster to run: First problem i encountered is the first part of the code this.Close(); should be Application.Exit(); this will make sure the program exits 100% for the updater because sometimes it doesnt exit fully and gives an error. change Try to if and catch to else in catch (else now) try this: MessageBox.Show("Up-To-Date Or No Network.", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); ; this is better because if an error occurs this will help you and help the end user as well. Having the program do nothing is not good for finding the problem. This Should Fix everything for the first part. For the Updater part only use these because there is no more .zip or .rar file (Having File.Delete(@".\Demo.exe"); after downloading it makes no sense)

    • @typeblvck.7918
      @typeblvck.7918 Před 2 lety

      System.Threading.Thread.Sleep(2000); File.Delete(@".\Demo.exe"); client.DownloadFile("yourhostinglink", @"Demo.exe"); MessageBox.Show("Updated To The Newest Version.", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); Process.Start(@".\Demo.exe"); this.Close();

    • @typeblvck.7918
      @typeblvck.7918 Před 2 lety

      in catch type somthing like this to know if there is an error: MessageBox.Show("There May Have Been An Error.", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start(@".\Demo.exe"); this.Close(); this should fix everything and make it work for sure. I will Share my code because mine finds the program on the desktop and updates it:

    • @typeblvck.7918
      @typeblvck.7918 Před 2 lety

      first part:--------- WebClient webClient = new WebClient(); if (!webClient.DownloadString("My Paste Bin Link").Contains("2.1")) { if (MessageBox.Show("New Update Found! Do You Want To Update?", "Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) using (var client = new WebClient()) { string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string folderName = Path.Combine(desktop, "Folder Name"); string path = Path.Combine(desktop, "Folder Name\\Updater.exe"); Process.Start(path); Application.Exit(); }

    • @typeblvck.7918
      @typeblvck.7918 Před 2 lety

      2nd part--------- WebClient webClient = new WebClient(); var client = new WebClient(); try { System.Threading.Thread.Sleep(2000); string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string path = (Path.Combine(desktopPath, "My app.exe")); File.Delete(Path.Combine(desktopPath, "My app.exe")); client.DownloadFile("My 000WebHost Link", (Path.Combine(desktopPath, "My app.exe"))); Process.Start(path); MessageBox.Show("Updated To The Newest Version.", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }

    • @typeblvck.7918
      @typeblvck.7918 Před 2 lety

      catch { MessageBox.Show("There May Have Been An Error.", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start("My app.exe"); this.Close(); } i had to replay on my comment because youtube kept deleting the long one comment

  • @theoryguides
    @theoryguides Před 2 lety

    What if I want to customize the update form, but it won't open!!??

    • @ISOPL2
      @ISOPL2 Před rokem

      because you put that code in initialization ¯\_(ツ)_/¯

  • @gdgust2547
    @gdgust2547 Před 2 lety

    when i make it and run it my eset and windows defender flags it as a trojan

  • @krisnarxf
    @krisnarxf Před 2 lety

    Is this can replace new file updater when old file updater open?

    • @gdgust2547
      @gdgust2547 Před 2 lety

      nope but you can make so the actual app downloads the updater like other way around

    • @krisnarxf
      @krisnarxf Před 2 lety

      @@gdgust2547 Ohh okay, ill figure it out

  • @ductptran1598
    @ductptran1598 Před 2 lety

    what about 2019, the zipfile not work

  • @AmeerYT
    @AmeerYT Před 3 lety

    very very very very very helpful <3 respect++++++++++++++++++

  • @BossBYT
    @BossBYT Před 3 lety

    Hello, my friend! I am creating a program and I do not have much experience in programming. I wonder if it can be done, to upload the program I make to my website where other users can download it? When I make a new version of the program, I will replace the old program on the website with a new one, at this point, will all the old versions of the programs on all other computers detect that an update is available where the user can update it. I just wonder if this is possible?

    • @vib2810
      @vib2810 Před 2 lety

      Hi! Checkout this method (using github and ClickOnce), which can do this for free: czcams.com/video/iMEGtrjMXPU/video.html

  • @AmosMcn
    @AmosMcn Před 3 lety

    how do u create a form on visual studio 2019 with a button to execute this command below? its like these: @echo off start SoulWorker100.exe IP:127.0.0.1 PORT:10000 MultiExecuteClient:yes SkipWMModule:yes its in a bat file to run the exe file of the game server that i tried to make a launcher from(they dont have launcher so). thanks for the answers.im trying to hide the server ip to the public so they wont see much info about it. im new to vs 2019 and i trying to help a friend to make a launcher for him

    • @MrSkips-zi9pi
      @MrSkips-zi9pi Před 3 lety

      you should likely obfuscate the .bat file and then run it using system disgnostics

  • @licun_water
    @licun_water Před 3 lety

    thank a lot!! bro~~~

  • @aauqa2164
    @aauqa2164 Před 3 lety

    How did you get that link on 000webhost? I have looked everywhere

  • @croowwz
    @croowwz Před 3 lety

    I solved the third problem, but now the download problem stops at 0.731 KB and then the file load for my project disappears, 13MB

  • @croowwz
    @croowwz Před 3 lety

    I fixed the first problem, but there is another problem when the download is complete it does not extract the file

    • @GalaxyTJ
      @GalaxyTJ Před 2 lety

      #region Private Properties private static string CurrentDirectory { get; } = Environment.CurrentDirectory; private static string ZipLocation { get; } = $"{CurrentDirectory}\\Venvep.zip"; private static string DirectoryLocaction { get; } = $"{CurrentDirectory}\\Venvep"; #endregion #region Private Helpers private static void DeleteDirectories(bool DeleteZip = true, bool DeleteDirectory = true) { if (DeleteZip && File.Exists(ZipLocation)) File.Delete(ZipLocation); if (DeleteDirectory && Directory.Exists(DirectoryLocaction)) Directory.Delete(DirectoryLocaction, true); } #endregion #region Events

  • @croowwz
    @croowwz Před 3 lety

    Everything is fine but there is a problem with the zip file that it downloads, the updater is deleted before extraction

  • @Eduardovsky
    @Eduardovsky Před 3 lety

    +respect

  • @diegomolina1071
    @diegomolina1071 Před 3 lety

    im having struggles with the updater because when i try to process.start("updater.exe) it wont load and also if i want to debug it, i cant put interuptions points on updater code cuz it bypass it can you help me with that ?

    • @unixity_WasTaken
      @unixity_WasTaken Před rokem

      its because u have to go to C:/Users/(your user)/source/repos/(your updater)/bin/debug and copy the exe to C:/Users/(your user)/source/repos/(your app)/bin/debug thats what i did and it worked

  • @uzegadmin3852
    @uzegadmin3852 Před 3 lety

    thank you

  • @vikal7058
    @vikal7058 Před 3 lety

    Bro you'r amazing respect+ for you <3

  • @mr.snailman7326
    @mr.snailman7326 Před 3 lety

    I got everything but when I click update it deletes the demo.exe and when it downloads the zip it becomes corrupted

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      Can you tell me which file got corrupted?

    • @mr.snailman7326
      @mr.snailman7326 Před 3 lety

      @@basicprogramming6959 the demo.zip

    • @mr.snailman7326
      @mr.snailman7326 Před 3 lety

      @@basicprogramming6959 when ever I click yes yo update it deletes the demo.exe like it is suppose to but when it downloads the demo.zip it is corrupted I’m using GitHub

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      @@mr.snailman7326 Then you are doing something wrong with downloading it from GitHub, personally I haven't used GitHub for this so I'm afraid I can't help you

    • @mr.snailman7326
      @mr.snailman7326 Před 3 lety

      @@basicprogramming6959 I don’t seem to be doing anything wrong because everything else works perfectly it’s just the file when it downloads the zip

  • @tetstentfry
    @tetstentfry Před 3 lety

    Habe gesehen du bist deutsch also stelle ich die frage in deutsch. wenn ich auf ja klicke das es updaten soll dann löscht es die exe und downloadet sie aber nicht wieder woran kann das liegen

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      I'm actually from Belgium and I speak Dutch although German is an official language here in Belgium so I can understand and speak a little bit german. What I understand is that you download the same file that you had? Then the only explanation, if you did correctly what I did, is that you didn't update your new exe to webhost (or any host you are using) make sure that if you have a newer version of the application that you upload that to your host and delete the old one

  • @BahtsizSSubay
    @BahtsizSSubay Před 3 lety

    what if we upload our zip file to google drive and we make it public, would it work?

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      I didn't try that but you can. Altough I believe it's not possible just try. Put your google drive link where the webhost link is

    • @BahtsizSSubay
      @BahtsizSSubay Před 3 lety

      @@basicprogramming6959 okay thanks for information I am gonna try

    • @frozen_mitko
      @frozen_mitko Před 2 lety

      @@BahtsizSSubay Does it work?

  • @batuhankeskin66
    @batuhankeskin66 Před 3 lety

    Thank you for the video, but I have a question. I want my program to download all files it has, and delete the old ones after downloading the new ones (not only the exe file). Do you know how I can achieve this? It doesn't look like a good way to delete files by their names since file names and file quantity might differ in different versions.

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      I'm afraid I can't help you in that. When I searched how to do this, my first idea was to change the files but it was impossible due to the name and overwriting.

    • @SanGraphic
      @SanGraphic Před 2 lety

      @@basicprogramming6959 late reply but he could put the program in a directory, and then clear the directory from all the files and then install new files

    • @EndlessNoChill
      @EndlessNoChill Před 8 měsíci

      Just have a code that makes them download into a zip or rar with said new files

  • @polyviospatseadis9777

    my update form doesnt show up do you know why?

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      What do you mean by not showing up? It's completely normal that when there is an update and you click to update it, that there will not be a visable form that pops up, it does all the coding in the background

    • @polyviospatseadis9777
      @polyviospatseadis9777 Před 3 lety

      @@basicprogramming6959 i found the issue thanks a lot, nice tutorial

    • @toprakgureli7233
      @toprakgureli7233 Před 3 lety

      @@polyviospatseadis9777 hey how did you solve it

    • @polyviospatseadis9777
      @polyviospatseadis9777 Před 3 lety

      @@toprakgureli7233 i put my files to public folder

  • @ZenReal
    @ZenReal Před 3 lety

    It says that ZipFile is not in the current context. Can you help me?

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      I haven't had that message before but I can only suggest a few answers. Are you sure your content that you downloaded from the internet is a zip file? Are you sure you put the zip file in the same folder as all the other files? Make sure you use (name).zip as where to store it and not something like ./(name).zip. Make sure you watch the video again to make sure you haven't skipped a step or you mistyped something. The code is in the description if you want to copy it and modify to your needs

    • @ZenReal
      @ZenReal Před 3 lety

      Thanks yes It’s a zip file I copied the code and I put it on the same host website you showed

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      @@ZenReal did it work?

    • @ZenReal
      @ZenReal Před 3 lety

      @@basicprogramming6959 I decided to go with a different thing

  • @talhabicer8100
    @talhabicer8100 Před 3 lety

    Thx man i sub u you are incredible <3

  • @zackok8685
    @zackok8685 Před 3 lety

    It keeps saying do u wanna update? after it runs again, it was 1.5.0, i updated to 1.5.1 then it keeps asking u wanna ypdate ? how to fix

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      Zack Ok Did you change the text in your pastebin? The code looks for the text in the pastebin. If the current file isn't the same version, it will ask for an update. So maybe you did not change the pastebin or you didn't change the text in your code itself what to look for.

    • @zackok8685
      @zackok8685 Před 3 lety

      @@basicprogramming6959 i had to go to properties of my projeect and change assembly u ddidnt mention that but its ok :D

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      Zack Ok Oeps, my bad if I missed something. I'm glad you found it

    • @Surronix
      @Surronix Před 3 lety

      @@basicprogramming6959 How do you solve it? I have the same problem, i went to properties of my project, assembly and then what?

    • @basicprogramming6959
      @basicprogramming6959 Před 3 lety

      @@Surronix I'm sorry but I didn't encounter his problem, maybe you can tag Zack Ok

  • @jarno2427
    @jarno2427 Před 4 lety

    Can you do a tutorial to add progress bar to see the progress?

    • @basicprogramming6959
      @basicprogramming6959 Před 4 lety

      I'm currently somewhat busy, I looked some video's up on youtube and I think that might help you. If it doesn't I will try to make some free time and figure it out myself.

    • @jarno2427
      @jarno2427 Před 3 lety

      @@basicprogramming6959 i can't a easy tutorial for progressbar

    • @iCostiG
      @iCostiG Před 3 lety

      @@jarno2427 set max value of progress bar to the amount of files to download and whenever a file is download step progress bar by 1

  • @igorruivo1976
    @igorruivo1976 Před 4 lety

    I did mine without a setup. Thanks for some of the ideas :D Btw, can anyone give me some kind of code review or contribution? github.com/igor-ruivo/generic-auto-updater

    • @basicprogramming6959
      @basicprogramming6959 Před 4 lety

      Awesome to hear, I usually don't make video's but I couldn't find a good file updater anywhere on the platform so I built mine from scratch. I'm glad you are also sharing your code to others!

  • @matiasjavierjimenez
    @matiasjavierjimenez Před 4 lety

    Good video man! I will implement and then I comment!

  • @thefrieber_362
    @thefrieber_362 Před 4 lety

    Thx man

  • @David2k18Star
    @David2k18Star Před 4 lety

    My updater is not in the same folder with my program.. Why???

    • @basicprogramming6959
      @basicprogramming6959 Před 4 lety

      I'm guessing that you forgot to add your updater to the .exe installer

  • @dizboiEntertainment
    @dizboiEntertainment Před 4 lety

    You deserve a sub man im ur first subscriber lmao