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

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024
  • 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();
    }

Комментарии • 85

  • @dizboiEntertainment
    @dizboiEntertainment 4 года назад +2

    You deserve a sub man im ur first subscriber lmao

  • @matiasjavierjimenez
    @matiasjavierjimenez 4 года назад +1

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

  • @vikal7058
    @vikal7058 3 года назад +2

    Bro you'r amazing respect+ for you

  • @eyalgerber
    @eyalgerber 2 года назад +1

    Very useful video! Thanks a lot!

  • @croowwz
    @croowwz 3 года назад +1

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

  • @theoryguides
    @theoryguides 2 года назад +1

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

    • @ISOPL2
      @ISOPL2 2 года назад

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

  • @trenenjoyer-o7f
    @trenenjoyer-o7f 4 года назад +1

    Thx man i sub u you are incredible

  • @niyomja
    @niyomja 2 года назад

    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.

  • @killua8397
    @killua8397 2 года назад

    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 3 года назад

    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

  • @AmeerYT
    @AmeerYT 3 года назад +1

    very very very very very helpful

  • @gdgust2547
    @gdgust2547 2 года назад

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

  • @mr.snailman7326
    @mr.snailman7326 3 года назад +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  3 года назад

      Can you tell me which file got corrupted?

    • @mr.snailman7326
      @mr.snailman7326 3 года назад

      @@basicprogramming6959 the demo.zip

    • @mr.snailman7326
      @mr.snailman7326 3 года назад

      @@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  3 года назад

      @@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 3 года назад

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

  • @BossBYT
    @BossBYT 3 года назад +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 2 года назад +1

      Hi! Checkout this method (using github and ClickOnce), which can do this for free:
      ruclips.net/video/iMEGtrjMXPU/видео.html

  • @croowwz
    @croowwz 3 года назад

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

    • @GalaxyTJ
      @GalaxyTJ 2 года назад

      #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

  • @Crisb-gi3sm
    @Crisb-gi3sm Год назад

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

  • @David2k18Star
    @David2k18Star 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад

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

  • @ZenReal
    @ZenReal 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад

      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 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад

      @@ZenReal did it work?

    • @ZenReal
      @ZenReal 4 года назад

      @@basicprogramming6959 I decided to go with a different thing

  • @krisnarxf
    @krisnarxf 3 года назад

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

    • @gdgust2547
      @gdgust2547 2 года назад

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

    • @krisnarxf
      @krisnarxf 2 года назад

      @@gdgust2547 Ohh okay, ill figure it out

  • @diegomolina1071
    @diegomolina1071 3 года назад

    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 Год назад

      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

  • @ductptran1598
    @ductptran1598 3 года назад

    what about 2019, the zipfile not work

  • @jarno2427
    @jarno2427 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад +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 4 года назад

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

    • @iCostiG
      @iCostiG 3 года назад

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

  • @licun_water
    @licun_water 3 года назад

    thank a lot!! bro~~~

  • @BahtsizSSubay
    @BahtsizSSubay 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад +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 4 года назад

      @@basicprogramming6959 okay thanks for information I am gonna try

    • @frozen_mitko
      @frozen_mitko 2 года назад

      @@BahtsizSSubay Does it work?

  • @nixdercom
    @nixdercom 3 года назад

    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  3 года назад

      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

  • @thefrieber_362
    @thefrieber_362 4 года назад +1

    Thx man

  • @batuhankeskin66
    @batuhankeskin66 4 года назад +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  4 года назад +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 3 года назад +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 11 месяцев назад

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

  • @Eduardovsky
    @Eduardovsky 3 года назад

    +respect

  • @polyviospatseadis9777
    @polyviospatseadis9777 4 года назад

    my update form doesnt show up do you know why?

    • @basicprogramming6959
      @basicprogramming6959  4 года назад +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 4 года назад +1

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

    • @toprakgureli7233
      @toprakgureli7233 3 года назад

      @@polyviospatseadis9777 hey how did you solve it

    • @polyviospatseadis9777
      @polyviospatseadis9777 3 года назад

      @@toprakgureli7233 i put my files to public folder

  • @uzegadmin3852
    @uzegadmin3852 3 года назад

    thank you

  • @ilovewomen2976
    @ilovewomen2976 2 года назад

    can someone post the solution?

  • @zackok8685
    @zackok8685 4 года назад

    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  4 года назад

      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 4 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  4 года назад

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

    • @Surronix
      @Surronix 3 года назад

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

    • @basicprogramming6959
      @basicprogramming6959  3 года назад

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

  • @AmosMcn
    @AmosMcn 3 года назад

    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 3 года назад

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