using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Net;
using System.Diagnostics;
using System.Text;
namespace Update_App
{
public partial class Form1 : Form
{
public Form1()
{
CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
private string applicationVersion = "", newVersion = "", aboutUpdate = "";
private string downloadURL = "DownloadURL";
private string W_dosya = Application.StartupPath + @"\update_001";
private void Button1_Click(object sender, EventArgs e)
{
string str = String.Format("Yeni sürüm mevcut!\nSizin sürümünüz: {0}.nYeni sürüm: {1}. ", applicationVersion, newVersion, aboutUpdate);
if (DialogResult.No != MessageBox.Show(str + "\nGüncellemeyi indirmek ister misiniz?", "Güncellemeyi kontrol et", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
try
{
WebClient W_Client = new WebClient();
W_Client.DownloadFileCompleted += W_Client_DownloadFileCompleted;
W_Client.DownloadFileAsync(new Uri(downloadURL), W_dosya);
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
}
private void W_Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
//İNDİRME BİTİNCEKİ İŞLEMLER
UpdateAPP();
}
private void Button2_Click(object sender, EventArgs e)
{
MessageBox.Show(Application.ExecutablePath);
}
private void UpdateAPP()
{
string mainPath = Application.ExecutablePath;
Process process = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.Arguments = "/C TIMEOUT /T 2&DEL " + mainPath + "&MOVE " + W_dosya + "," + mainPath + "&START " + mainPath;
process.StartInfo = info;
process.Start();
Application.Exit();
}
}
}