会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
做有意义的事儿
天行健,君子以自强不息!
一段软件更新程序(使用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();
}
}
}
posted on
2007-09-12 15:07
恋地高飞
阅读(
263
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
管理