Hello there guys, thanks for reading...
I know that, there are features in VS2010 that allow this to happen...
But in my case, I would like to keep it simple and Manual...
For example... this is the situation I would like to create:
I want to have a .ini file that, will contain the last update text, for example 1.0
Then, when the program is executed, I want it to make a http connection, and compare the local .ini file, with the one on the http server...
if the number in the http server, is greater than the local one, it will download certain file... (update) ...
Thanks guys !!
Loading
thiago costaPosted Jan 7, 2011, 7:51 PM
This is what I did:
I came to the conclusion that using a txt file will be the best way for me ... since readstream wouldn't read .ini .. lol I dont know why
HAHAHAHHAHA I am a newbie, I just made the 2 text boxes invisible because I am just using them to compare the 2 values...
HAHAHAHAH omg now noobiesh was that???
But it works ! :D
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace Authenticate
{
public partial class Authenticate : Form
{
public Authenticate()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int serverV;
serverV = Convert.ToInt32(TBserver.Text);
serverV = int.Parse(TBserver.Text);
int localV;
localV = Convert.ToInt32(TBlocal.Text);
localV = int.Parse(TBlocal.Text);
if (serverV > localV)
{ //DO THE UPDATE CODE }
else
{ //DO NOT DO THE UPDATE CODE }
}
private void Authenticate_Load(object sender, EventArgs e)
{
WebClient Client = new WebClient();
Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
Client.DownloadFileAsync(new Uri("http://98.118.57.8/anti/version.txt"), "versionS.txt");
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
//progressBar1.Value = e.ProgressPercentage;
}
private void Completed(object sender, AsyncCompletedEventArgs e) {
StreamReader SRlocal = new StreamReader("versionL.txt");
TBlocal.Text = SRlocal.ReadToEnd();
SRlocal.Close();
StreamReader SLserver = new StreamReader("versionS.txt");
TBserver.Text = SLserver.ReadToEnd();
SLserver.Close();
}//what ever to do after completed
}
}
thiago costaPosted Jan 7, 2011, 6:28 PM
http://98.118.57.8/anti/version.jpg
As i show in that picture, I don't mind if it is a text file, or a .ini file... but that's kind of how I want to do it...
If the SAME file on the server, has a greater number than the Local one, I want the update to install automatically...
The extract and install parts I will be ok with...
The only thing I don't know how do to, is read the text inside the text file, and compare...
I was thinking about this:
Downloading text file at program's startup,
Now that the file is local, How do I compare the 2 text files? ...
How do I Read the LINE 1 of the file, and transform it in an integer..
raw example...
int updateserver.ini.line1 = i;
int updatelocal.ini.line1 = p;
if(i > p);
{UPDATE}
else
{return}
so pretty much, I just want to read the number off of the first line, and transform it as an integer...
I will not have dashes etc...
It will be like...
1
or
2
to make things easy...
THANKS GUYS :D
-----EDIT-----
i was thinking... will this work?
That might work right?
Or do I have to do..
int textBox1.Text ?
int textBox2.Text ?
.... Thaths the only idea I can come up with
FroglegPosted Jan 7, 2011, 5:07 PM
thiago costaPosted Jan 7, 2011, 4:48 PM
But, would you know a way to do it off of a .ini file instead? ... I mean..
in most MMO games, there is a file called version.ini ...
In the version . ini, there is usually just 1 line..
I want to try to do it with out using XML, But I will definitely keep your tutorial for future reference.
Thanks man !!!
Roy SPosted Jan 7, 2011, 3:56 PM
http://themech.net/2008/05/adding-check-for-update-option-in-csharp/