zoukankan      html  css  js  c++  java
  • 一段软件更新程序(使用WinRar压缩包)

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Net;
    using System.Diagnostics;

    namespace UpDate
    {
        public partial class Form1 : Form
        {
            private WebClient update = new WebClient();

            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                string URL = @"https://files.cnblogs.com/mossan/Zhongwen.rar";
                int n = URL.LastIndexOf('/');
                string fileName = URL.Substring(n + 1, URL.Length - n - 1);

                if (!(Directory.Exists(Application.StartupPath + "\\update")))
                {
                    Directory.CreateDirectory(Application.StartupPath + "\\update");
                }

                try { update.DownloadFile(URL, Application.StartupPath + "\\update\\" + fileName); }
                catch (WebException ex) { MessageBox.Show(ex.Message, "Error"); }

                try
                {
                    Process UnWinrar = new Process();
                    UnWinrar.StartInfo.FileName = "WinRAR.exe";
                    UnWinrar.StartInfo.Arguments = "e -o+ \"" + Application.StartupPath + "\\update\\" + fileName + "\"" + " \"" + Application.StartupPath + "\\update" + "\"";
                    UnWinrar.Start();
                    MessageBox.Show("解压缩完成!");
                    File.Copy(Application.StartupPath + "\\update\\" + "Zhongwen.exe", Application.StartupPath + "\\Zhongwen.exe", true);

                    Process ProZhongwen = new Process();
                    ProZhongwen.StartInfo.FileName = Application.StartupPath + "\\Zhongwen.exe";
                    ProZhongwen.Start();
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                this.Close();
            }
        }
    }

  • 相关阅读:
    判断
    迭代器
    如何关闭弹框以外的区域来关闭弹框?
    如何使APP端的滑动事件兼容PC端?
    获取元素相对于视窗的位置?
    如何获取一个元素没有在style和样式表中设置的样式的值?
    如何寻找一个数值数组中的最大元素?
    table表格中字母和数字如何换行?
    js中将字符串作为函数名来调用的方法
    web开发中如何使用引用字体
  • 原文地址:https://www.cnblogs.com/mossan/p/719926.html
Copyright © 2011-2022 走看看