Q:

How to verify and update a program version

So I want to create a really simple function. When the form loads, a message box pops up to prompt user to upgrade. If Yes is clicked, it downloads a txt file with latest version and information on where to download the latest program. If the version is higher, it download the actual update. But if equal, just cancels It's really simple but I cant find an answer for it anywhere :(
Here was my previous approach:
        WebRequest wr = WebRequest.Create(new Uri("https://pastebin.com"));
        WebResponse ws = wr.GetResponse();
        StreamReader sr = new StreamReader(ws.GetResponseStream());

        string currentversion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
        string newversion = sr.ReadToEnd();

        if (currentversion.Contains(newversion))
        {
            System.Windows.Forms.MessageBox.Show("You Program is Up-to-Date", "Information",
                        MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
        else
        {
            System.Windows.Forms.MessageBox.Show("A new Version of the Program was detected! The program will now update to give you the latest features!", "Important",
                        MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del " +
      Application.ExecutablePath);
            Application.Exit();

A:

I made this example of how to check the local version of an application and compare it to a remote version. The remote file in this case is a simple txt that contains the version number and in the following line a brief information of where to download the update if necessary.
version-remote.txt 
2.0.0.0
To download the latest version of the App, go to the website below.

Example Code:
    private void f_main_Load(object sender, EventArgs e)
    {
        VerifyUpdate();
    }

    //verifies that the local version 
    //is different from the remote version
    private void VerifyUpdate()
    {
        //version local assembly version
        var vlocal = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
        //download remote version
        var vremot = new Version(DoenloadVersion().FirstOrDefault());

        var result = vlocal.CompareTo(vremot);
        if (result < 0)
        {
            UpdateQuestion();
        }
        else if (result > 0)
        {
            DowngradeQuestion();
        }
        else
        {
            AlreadyUpdateQuestion();
        }
    }

    //downloads the file containing the latest 
    //version number
    private string[] DoenloadVersion()
    {
        string remoteUri = "https://storage.googleapis.com/albtoos_pessoal/version-remote.txt";
        string localsave = ($"{System.IO.Directory.GetParent(@"../../").FullName}/version-remote.txt");

        WebClient webversion = new WebClient();

        //makes a copy of the remote version in the root folder
        webversion.DownloadFile(remoteUri, localsave);

        return File.ReadAllLines(localsave);
    }

    private void AlreadyUpdateQuestion()
    {
        DialogResult option = MessageBox.Show("You already have the last version!", "Program", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        if (option == DialogResult.Yes)
        {
            //do something
        }
    }

    private void UpdateQuestion()
    {
        DialogResult option = MessageBox.Show("Need Update", "Program", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
        if (option == DialogResult.Yes)
        {
            //do download
        }
    }

    private void DowngradeQuestion()
    {
        DialogResult option = MessageBox.Show("Need Downgrade", "Program", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
        if (option == DialogResult.Yes)
        {
            //do downgrade
        }
    }

The part of AlreadyUpdateQuestion(), UpdateQuestion() and DowngradeQuestion() is more like an illustration, because here it depends a lot on how you want to work with the user. But if you need to download something bigger, such as the update installation file, you will need to work with mehlor in this function.
There is probably a better way to do this, but follow this as an initial reference.

