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();
            }

        }

    }

  • 相关阅读:
    每日一题_191101
    阿基米德三角形(交互式学件)
    2018四川高考数学(全国卷3)理科21题以泰勒公式为命题背景(同时深挖去年高考题)和它的另类解法的瞎谈
    给老谢画的图(平面几何中的动点与最值问题)
    2018四川高考文科21题
    数学解题的思维过程
    Qt Creator 模块QtSql
    QT Creator快捷键不能用
    QT 随机数
    C++ 4 种具有更 为准确语义的新强制转换类型
  • 原文地址:https://www.cnblogs.com/xlfj521/p/890762.html
Copyright © 2011-2022 走看看