-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuncelleme.cs
104 lines (78 loc) · 3.21 KB
/
Guncelleme.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.Zip.Extensions;
namespace XCubeCrm.UI.Win
{
public partial class Guncelleme : Form
{
string appPath = Application.StartupPath + "\\XCubeCrm.UI.Update.exe";
string appPathrar = Application.StartupPath + "\\Update.zip";
public Guncelleme()
{
InitializeComponent();
}
private void ProgressChanged(object sneder, DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
label2.Text = "Downloading... " + BytesToString(e.BytesReceived) + " / " + BytesToString(e.TotalBytesToReceive);
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
label2.Text = "Güncelleme var";
//ZipFile.ExtractToDirectory(appPathrar, Application.StartupPath);
//System.Diagnostics.Process.Start(appPath);
//Process.Start("taskkill", "/F /IM Update.exe");
using (var archive = ZipFile.OpenRead(appPathrar))
{
foreach (var file in archive.Entries)
{
var completeFileName = Path.Combine(Application.StartupPath, file.FullName);
var directory = Path.GetDirectoryName(completeFileName);
if (!Directory.Exists(directory) && !string.IsNullOrEmpty(directory))
Directory.CreateDirectory(directory);
if (file.Name != string.Empty)
file.ExtractToFile(completeFileName, true);
this.Hide();
}
}
}
public static void ExtractToDirectory(string archiveFileName, string destinationDirectoryName, bool overwrite)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
//https://www.instagram.com/canasikk/
//https://github.com/canasikk
timer1.Stop();
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("http://www.burpos.com/Update.zip"), appPathrar);
}
private static string BytesToString(long byteCount)
{
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
long bytes = Math.Abs(byteCount);
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
//https://www.instagram.com/canasikk/
//https://github.com/canasikk
return (Math.Sign(bytes) * num).ToString() + suf[place];
}
private void Guncelleme_Load(object sender, EventArgs e)
{
}
private void Guncelleme_Load_1(object sender, EventArgs e)
{
}
}
}