The code below works... BUT, I am using invisible textboxes to store the values inside versionS and versionL ...
How can I do the same function, and NOT have to use these invisible textboxes to store the values? even though it works,
I'd like to avoid using WorkArrounds for this kind of stuff, to improve my learning...
THANKS GUYS ! :D
C#
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;
namespaceAuthenticate
{
publicpartialclassAuthenticate : Form
{
publicAuthenticate()
{
InitializeComponent();
}
privatevoidbutton1_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 }
}
privatevoidAuthenticate_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");
}
privatevoidProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
//progressBar1.Value = e.ProgressPercentage;
}
privatevoidCompleted(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
}
}
... so in this case, I am transferig the value from the text file, into the invisible textbox, then converting the textbox into an integer... But... I would like to store the 2 values other than in invisible textboxes..
Thank you
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Kevin Aung46 reputationPosted Jan 8, 2011, 4:31 PM EST
private void GetVersions()
{
// Read file in stream reader
string versionL = SRlocal.ReadToEnd();
string versionS = SRlocal.ReadToEnd();
int vL = Convert.ToInt16(versionL);
int vS = Convert.ToInt16(versionS);
}
thiago costaRank #6,113 · 276 reputationPosted Jan 8, 2011, 4:48 PM EST
THANK YOU !!!!
IT WORKS !!!! ....
---EDIT---
Works beautiful.
Thanks mate...
d .Parse