Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Net;
- namespace Updater
- {
- public partial class frmMainWindow : Form
- {
- public frmMainWindow()
- {
- InitializeComponent();
- }
- WebClient myWebclient = new WebClient();
- string Temp;
- string checkversion;
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- myWebclient.DownloadFileCompleted += OnDownloadComplete;
- myWebclient.DownloadFileAsync(new Uri("https://dl.dropbox.com/s/ahysy3ppgbewznb/Version.txt?dl=1"), Temp + "VersionNumber.txt");
- }
- private void OnDownloadComplete(object sender, AsyncCompletedEventArgs e)
- {
- myWebclient.Dispose();
- var reader = new System.IO.StreamReader(Temp + "VersionNumber.txt");
- checkversion = reader.ReadToEnd();
- reader.Dispose();
- DownloadNewVersion();
- }
- private void DownloadNewVersion()
- {
- if (checkversion.Contains(Application.ProductVersion))
- {
- MessageBox.Show("You have the latest version!", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- else
- {
- myWebclient.DownloadFile("https://dl.dropbox.com/s/30pbkeg3nfr662y/NewVersion.txt?dl=1", Temp + "Downloadlink.txt");
- myWebclient.Dispose();
- var Downloadlink = new System.IO.StreamReader(Temp + "Downloadlink.txt");
- string Link = Downloadlink.ReadToEnd();
- Downloadlink.Dispose();
- FolderBrowserDialog SelectFolder = new FolderBrowserDialog();
- SelectFolder.ShowDialog();
- string Location = SelectFolder.SelectedPath;
- System.IO.Directory.CreateDirectory(Location + @"\NewVersion");
- myWebclient.DownloadFile(Link, Location + "Update.exe");
- myWebclient.Dispose();
- }
- }
- private void frmMainWindow_Load(object sender, EventArgs e)
- {
- Temp = System.IO.Path.GetTempPath();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement