root/trunk/BazaZamowien/FormBadVer.cs @ 820

Wersja 710, 2.7 KB (wprowadzona przez dorota, 18 years temu)

baza zamowien i premii 1.0.0.1

Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using System.Net;
9using System.Diagnostics;
10using BazaZamowien.Classes;
11
12namespace BazaZamowien
13{
14    public partial class FormBadVer : Form
15    {
16        private WebClient webClient;
17        private bool isBusy = false;
18        const string strUrl = "http://www.infocity.pl/baza_zamowien/Updater.exe";
19
20        public FormBadVer()
21        {
22            InitializeComponent();
23           
24            webClient = new WebClient();
25            webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
26        }
27
28        private void button1_Click(object sender, EventArgs e)
29        {
30            string updater = Environment.CurrentDirectory + "\\Updater.exe";
31
32           if (System.IO.File.Exists(updater))
33            {
34                startUpdater();
35            }
36            else
37            {
38                isBusy = true;
39                webClient.DownloadFileAsync(new Uri(strUrl), Environment.CurrentDirectory + "\\Updater.exe");           
40            }
41        }
42
43        private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
44        {
45            isBusy = false;
46                     
47            if (e.Error == null)
48            {
49                startUpdater();
50            }
51            else
52            {
53                MessageBox.Show("B³¹d aktualizacji oprogramowania: " + e.Error.Message, "Aktualizacja oprogramowania", MessageBoxButtons.OK, MessageBoxIcon.Error);
54                Close();
55            }
56        }
57
58        private void startUpdater()
59        {
60            string updater = Environment.CurrentDirectory + "\\Updater.exe";
61
62            Close();
63            ProcessStartInfo startInfo = new ProcessStartInfo();
64            startInfo.Arguments = "2";
65            startInfo.FileName = updater;
66
67            try
68            {
69                Process.Start(startInfo);
70            }
71            catch (Exception ex)
72            {
73                MessageBox.Show(ex.ToString());
74            }
75        }
76
77        private void Extract(string zipFileName, string destinationPath)
78        {
79            Shell32.IShellDispatch4 sc = (Shell32.IShellDispatch4) new Shell32.ShellClass();
80         //   Shell32.ShellClass sc = new Shell32.ShellClass();
81            Shell32.Folder SrcFlder = sc.NameSpace(zipFileName);
82            Shell32.Folder DestFlder = sc.NameSpace(destinationPath);
83            Shell32.FolderItems items = SrcFlder.Items();
84            DestFlder.CopyHere(items, 20);       
85        }
86
87
88    }
89}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.