自我更新模块

时间:2014-11-10 15:01:08
【文件属性】:

文件名称:自我更新模块

文件大小:2KB

文件格式:CS

更新时间:2014-11-10 15:01:08

更新 C#

根据自定义文件进行程序更新 static void Main() { try { System.Net.WebClient download = new System.Net.WebClient(); download.BaseAddress = "ftp://ftp.ftp.com/System/"; download.DownloadFile("upgrade.list", "upgrade.list"); System.IO.StreamReader a = new System.IO.StreamReader("upgrade.list"); bool up = true; string upfile = a.ReadLine(); while (up) { upfile = a.ReadLine(); if (upfile == null) up = false; else { if(upfile.LastIndexOf('\\')>-1) System.IO.Directory.CreateDirectory(upfile.Substring(0, upfile.LastIndexOf('\\'))); download.DownloadFile(upfile, upfile); } } download.Dispose(); MessageBox.Show("升级完毕"); } catch (Exception ex) { MessageBox.Show("升级失败:" + ex.Message); } System.Diagnostics.Process tmpProcess = new System.Diagnostics.Process(); tmpProcess.StartInfo.FileName = Application.StartupPath + "\\myststem.exe"; tmpProcess.Start(); }


网友评论