How to make an automatic updater in Visual Studio! | C# | 2020 | With and without Setup!

Sdílet
Vložit
  • čas přidán 19. 02. 2020
  • 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();
    }

Komentáře • 85

  • @vikal7058
    @vikal7058 Před 3 lety +2

    Bro you'r amazing respect+ for you

  • @dizboiEntertainment
    @dizboiEntertainment Před 4 lety +2

    You deserve a sub man im ur first subscriber lmao

  • @eyalgerber
    @eyalgerber Před rokem +1

    Very useful video! Thanks a lot!

  • @matiasjavierjimenez
    @matiasjavierjimenez Před 4 lety +1

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

  • @croowwz
    @croowwz Před 3 lety +1

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

  • @talhabicer8100
    @talhabicer8100 Před 3 lety +1

    Thx man i sub u you are incredible

  • @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

  • @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

  • @thefrieber_362
    @thefrieber_362 Před 4 lety +1

    Thx man

  • @AmeerYT
    @AmeerYT Před 3 lety +1

    very very very very very helpful

  • @licun_water
    @licun_water Před 3 lety

    thank a lot!! bro~~~

  • @gdgust2547
    @gdgust2547 Před 2 lety

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

  • @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.

  • @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

  • @Eduardovsky
    @Eduardovsky Před 3 lety

    +respect

  • @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 rokem

      #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

  • @BossBYT
    @BossBYT Před 3 lety +2

    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 +1

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

  • @theoryguides
    @theoryguides Před 2 lety +1

    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 ¯\_(ツ)_/¯

  • @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

  • @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.

  • @David2k18Star
    @David2k18Star Před 4 lety

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

  • @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

  • @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

  • @ilovewomen2976
    @ilovewomen2976 Před rokem

    can someone post the solution?

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

    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

  • @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 +1

      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 rokem

      @@BahtsizSSubay Does it work?

  • @batuhankeskin66
    @batuhankeskin66 Před 3 lety +3

    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 +1

      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 +1

      @@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 7 měsíci

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

  • @jarno2427
    @jarno2427 Před 3 lety

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

    • @basicprogramming6959
      @basicprogramming6959  Před 3 lety +1

      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 2 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

  • @ductptran1598
    @ductptran1598 Před 2 lety

    what about 2019, the zipfile not work

  • @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

  • @polyviospatseadis9777
    @polyviospatseadis9777 Před 3 lety

    my update form doesnt show up do you know why?

    • @basicprogramming6959
      @basicprogramming6959  Před 3 lety +1

      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 +1

      @@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

  • @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