Hello I want to create an update mechanic in my program (Windows Form Application). It makes it so when they press login, if there is an update; the program will first update then let them login.
if (!new WebClient().DownloadString(
"ftp://username:password@wdasd.bplaced.net/test.txt").Contains("1.0.0.0")) {
}
else
{
if (MessageBox.Show("New Update! Would you like to update?", "Yay!",
MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
System.Windows.Forms.DialogResult.Yes)
{
Process.Start("ftp://username:password@wdasd.bplaced.net/wdasd.bplaced.net.zip");
}
}
and the Button code
private void button2_Click(object sender, EventArgs e)
{
//Hash
var hash = SecurePasswordHasher.Hash("password");
//Verify
var result = SecurePasswordHasher.Verify("password", hash);
if (
txtUsername.Text == "" || txt_Password.Text == "")
{
MessageBox.Show("Please provide a Username and Password");
return;
}
try
{
//Create SqlConnection
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("Select * from [break].[dbo].[tabl_login] where UserName=@username and Password=@password", con);
cmd.Parameters.AddWithValue("@username", txtUsername.Text);
cmd.Parameters.AddWithValue("@password", txt_Password.Text);
con.Open();
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapt.Fill(ds);
con.Close();
int count = ds.Tables[0].Rows.Count;
//If count is equal to 1, than show frmMain form
if (count == 1)
{
MessageBox.Show("Login Successful!");
if (!new WebClient().DownloadString(
"ftp://username:password@wdasd.bplaced.net/test.txt").Contains("1.0.0.0")) {
}
else
{
if (MessageBox.Show("New Update! Would you like to update?", "Yay!",
MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
System.Windows.Forms.DialogResult.Yes)
{
Process.Start("ftp://username:password@wdasd.bplaced.net/wdasd.bplaced.net.zip");
}
}
}
else
{
MessageBox.Show("Login Failed!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I am pretty sure Process.Start is not correct. What would I type into there in order for the program to look into the FTP server for an update?
Please no ClickOnce, I want it to load up update when they click login. Not have the installer.