由於boss不讓使用smart client,所以只好使用下載-覆蓋-重啟應用程式的三步驟
首先,我們需要一個Loader程式,來引導主程式
http://files.cnblogs.com/wildfish/AppUpdateStarter.rar
第二,在主程式中
//擷取船塢系統的程式集
//注意區分大小寫
Assembly asm = Assembly.LoadFrom(Application.StartupPath + Path.DirectorySeparatorChar + "SD.dll");
//擷取版本資訊
string curVersion = VersionConfig.GetVersion(asm);
//確認視窗
Form_UpdateConfirm confirmForm = new Form_UpdateConfirm();
//校正版本對象
CheckVersionSystem checkVersion = new CheckVersionSystem(confirmForm, "SDSYSTEM", curVersion, Application.StartupPath, false);
bool needRestart = false;
//更新狀態視窗
Form_UpdateState stateForm = new Form_UpdateState(checkVersion);
//判斷版本,嘗試升級
checkVersion.TryUpdate(ref needRestart);
//如果需要重新啟動
if (needRestart)
{
Environment.ExitCode = 2; //the surrounding AppStarter must look for this to restart the app.
MessageBox.Show("提示:系統更新完畢!請重新啟動!", "更新完畢");
}
else
{
Form_SD_Main doc_SD = new Form_SD_Main();
Application.Run(doc_SD);
}
第三步,安裝程式要按照如下目錄方式來製作
外層的目錄,一個Loader程式,一個設定檔,應用程式的檔案夾
這個是Penavicoxm檔案夾內部的內容
這樣我們就可以可控的控制應用系統的升級
當然了這種方式存在一種缺點,不能及時有效讓使用者更新,使用者只有重新進入系統的時候才會體現更新
如果為了比較及時地,最好使用smart client,或者用b/s架構:)