• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tutorial] Making a "Check on updates" form
#1
Information 
Fuu , me no leecher @OrangePL

hey guys,

This is my first tutorial about C#, i will explain easy thing, which allows you make things like - check on updates, or just download bar.

You need:
  • Visual C#
  • FTP or file hoster

Usage:
That's just easy code which checks number, and downloads file.
When you updated your program, you should re-upload it to SAME address and edit your prog.rtf file - make first line number bigger, and make same number in new program version. ( ex: string CurrentVersion = "22"; and first line in prog.rtf must be 22 )

First of all you need to make good interface, like:
[Image: o3345aaaaaaaaaaaaaaaaaaaaag8.png]

Now make file prog.rtf and add into file, upload to your ftp(ex: www.blablalba.com/files/prog/ )
that file must have 2 lines: first line - version, second line - link to file
Ex:
Code:
22
www.blalblalba.com/files/prog/myprog.rar

Now need to make main checking.....
1. Double click on your "Check" button. Code will looks like:
Code:
private void checkForUpdatesButton_Click(object sender, EventArgs e)
{
          
}
2. Now need to add "file checking" thing which reads txt file.
NOTE: Current version value must be bigger than number in .txt file! That's main thing...
That's reads your rtf file from ftp and checks if current version less than num in file.
Code:
private void checkForUpdatesButton_Click(object sender, EventArgs e)
        {
            string CurrentVersion = "21";  // CURRENT VERSION MUST BE LESS OR SAME
            WebRequest request = WebRequest.Create("http://blablabla.com/files/prog/prog.rtf");
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string NewestVersion = reader.ReadLine();
            string Link = reader.ReadLine();
            if (NewestVersion != CurrentVersion)
            {
                // continue
            }
            else
            {
                MessageBox.Show("Can't find any update.",
            "Update");
            }
        }
That's checks on update by checking values...

Now i need to add downloading thing. That's checks SECOND line and downloads it.
Code:
WebRequest request = WebRequest.Create("http://blablalba.com/files/prog/prog.rtf");
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string NewestVersion = reader.ReadLine();
            string Link = reader.ReadLine();
                MessageBox.Show("A new version is available! Version: " + NewestVersion + "",
            "Updating");
                WebClient wc = new WebClient();
                wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
                wc.DownloadFileAsync(new Uri(Link), @Directory.GetCurrentDirectory() + "/myprogram.rar");

4. Making moving bar.
Now add:
Code:
public void wc_DownloadProgressChanged(Object sender, DownloadProgressChangedEventArgs e)
        {
            progressBar2.Value = e.ProgressPercentage;
        }
That's already called.

Result code:
Code:
private void checkForUpdatesButton_Click(object sender, EventArgs e)
        {
            string CurrentVersion = "21";  // CURRENT VERSION MUST BE LESS OR SAME
            WebRequest request = WebRequest.Create("http://blablabla.com/files/prog/prog.rtf");
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string NewestVersion = reader.ReadLine();
            string Link = reader.ReadLine();
            if (NewestVersion != CurrentVersion)
            {
            string Link = reader.ReadLine();
                MessageBox.Show("A new version is available! Version: " + NewestVersion + "",
            "Updating");
                WebClient wc = new WebClient();
                wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
                wc.DownloadFileAsync(new Uri(Link), @Directory.GetCurrentDirectory() + "/myprogram.rar");
            }
            else
            {
                MessageBox.Show("Can't find any update.",
            "Update");
            }
        }
       public void wc_DownloadProgressChanged(Object sender, DownloadProgressChangedEventArgs e)
        {
            progressBar2.Value = e.ProgressPercentage;
        }


C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
  Reply
#2
lol, a irl friend (@Back2Real ) of mine (which you know) just told me that he told you how to do this Tongue
He also said that he doesn't care, according to him, "it's common knowledge which everyone should know"

Good job on the tutorial, though.
  Reply
#3
(02-01-2012, 10:04)Rendflex Wrote: lol, a irl friend (@Back2Real ) of mine (which you know) just told me that he told you how to do this Tongue
He also said that he doesn't care, according to him, "it's common knowledge which everyone should know"

Good job on the tutorial, though.

he didnt tell it to me. he just said reader code

me no leecher ftw1
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
  Reply
#4
Leecher.
  Reply
#5
Here's an idea, use pastebin (you'll need an account) to store that data. Just make sure to put the link to the raw link in the program. Nyan Cat
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#6
thanks, i rearry rike it
  Reply
#7
I will make "How to create a autoupdate - the way microsoft wants you to do it" this evening
  Reply
#8
(02-01-2012, 10:14)Se7en Wrote:
(02-01-2012, 10:04)Rendflex Wrote: lol, a irl friend (@Back2Real ) of mine (which you know) just told me that he told you how to do this Tongue
He also said that he doesn't care, according to him, "it's common knowledge which everyone should know"

Good job on the tutorial, though.

he didnt tell it to me. he just said reader code

me no leecher ftw1

Someone always tells you something before you do something, Troll

Good job

  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Making an apocalyptic themed Minecraft map AZUMIKKEL 54 25,828 08-31-2013, 02:54
Last Post: AZUMIKKEL
  Making a Heli's angles match my angles? akillj 1 2,459 06-16-2013, 15:01
Last Post: Yamato
  How do you guys check for errors when scripting? akillj 6 3,946 06-15-2013, 10:48
Last Post: Yamato
  Making a harrier crash into the map? akillj 6 4,425 06-09-2013, 05:57
Last Post: akillj
Brick Lesson 3: Making game in C++ Nekochan 2 3,274 06-03-2013, 15:25
Last Post: Nekochan
  Making a gametype multi-rounded? DidUknowiPwn 6 4,171 04-22-2013, 22:14
Last Post: Pozzuh
  Do you play runescape? :D check this out xD [BTK]Foxy 1 2,808 04-05-2013, 18:16
Last Post: SuperNovaAO
Information [Tutorial] Making MORE glass in your form. Nekochan 27 10,874 03-22-2013, 22:04
Last Post: kokole
  Help CPU Check bypass DemoroCZ 1 2,369 03-20-2013, 14:30
Last Post: JariZ
Rainbow Lesson 1: Making game in C++ Nekochan 6 4,740 02-04-2013, 15:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)