forked from fredriksa/WoWLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersionChecker.cs
65 lines (52 loc) · 1.99 KB
/
VersionChecker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Windows.Forms;
namespace Launcher
{
class VersionChecker
{
public static bool checkForNewVersion()
{
using (var client = new WebClient())
{
try
{
if (File.Exists("launcher.version"))
File.Delete("launcher.version");
string resourceTarget = "http://waloria.com/launcher/launcher.version";
if (ResourceHelper.resourceExists(resourceTarget))
client.DownloadFile(resourceTarget, "launcher.version");
}
catch (Exception e) { }
}
if (!File.Exists("launcher.version")) return false;
string versionString = File.ReadAllText("launcher.version");
double version = double.Parse(versionString);
if (Form1.version == version)
return false;
using (var client = new WebClient())
{
try
{
if (File.Exists("message.version"))
File.Delete("message.version");
string resourceTarget = "http://waloria.com/launcher/message.version";
if (ResourceHelper.resourceExists(resourceTarget))
client.DownloadFile(resourceTarget, "message.version");
} catch (Exception e) { }
}
string messageString = File.ReadAllText("message.version");
MessageBox.Show(messageString, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (File.Exists("launcher.version"))
File.Delete("launcher.version");
if (File.Exists("message.version"))
File.Delete("message.version");
return true;
}
}
}