Updater up = null;
try
{
up = new Updater(Assembly.GetExecutingAssembly());
if (up.CheckUpdate())
{
Utility.ShowInfoMessage("檢測到新版本,單擊確定後開始更新。");
up.BeginUpdate();
Application.Exit();
return;
}
else
{
// 自我更新更新程式本身
string file1 = Path.Combine(Application.StartupPath, "UpdaterExc.exc");
string file2 = Path.Combine(Application.StartupPath, "UpdaterExc.exe");
if (File.Exists(file1))
File.Replace(file1, file2, null, true);
}
}
catch (Exception e) { /* 記錄日誌 */ }
CheckUpdate() 比對伺服器版本。BeginUpdate() 下載並套用所有缺失版本。.exc → .exe)。
點擊「更新」即可自動完成增量更新。