Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net;
- using System.IO;
- using System;
- using System.Globalization;
- namespace Update_V1
- {
- public partial class Form1
- {
- public static string updateServer = "http://caimanssoft.do.am/Programm/";
- public static int currentVersion = 0;
- static void Main()
- {
- string[] UpdateInfo;
- UpdateInfo = GetUpdateInfo(updateServer);
- if (currentVersion < Convert.ToDouble(UpdateInfo[0], CultureInfo.InvariantCulture))
- {
- Console.WriteLine("Обнаружена новая версия программы, начинается загрузка файлов!");
- for (int i = 1; i < UpdateInfo.Length; i++)
- {
- File.WriteAllBytes(UpdateInfo[i].Replace("\r", ""), DownloadFile(updateServer + UpdateInfo[i].Replace("\r", "")));
- }
- Console.WriteLine("Обновление успешно скачалось");
- }
- else
- {
- Console.WriteLine("Обновление не требуется");
- }
- Console.ReadKey();
- }
- public static byte[] DownloadFile(string url)
- {
- var wc = new WebClient();
- return wc.DownloadData(url);
- }
- public static string[] GetUpdateInfo(string url)
- {
- var wc = new WebClient();
- wc.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36";
- return wc.DownloadString(updateServer + "update_info.txt").Split('\n');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment