91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

一款C#開發(fā)的通用的自動更新程序,包含源碼。按步驟包含:檢查更新,關(guān)閉打開的程序,備份程序,按文件清單更新文件,成功后更新程序版本號和更新時間,失敗后還原程序,最后刪除備份程序。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Configuration;
using?System.Diagnostics;
using?System.IO;
using?System.Windows.Forms;
using?System.Net;
using?System.Threading;

namespace?AutoUp
{
????public?class?AutoUpdate
????{
????????UpdateConfigModel?_model?=?new?UpdateConfigModel();
????????string?_appbaseDir?=?““;//本地應(yīng)用程序根目錄
????????string?_remoteDir?=?““;//服務(wù)器更新文件根目錄
????????string?_backDir?=?““;//本地文件備份路徑


????????//公共方法
????????private?bool?Work(Func?func?string?workName?string?faildMessage)
????????{
????????????bool?flag?=?false;
????????????try
????????????{
????????????????if?(!string.IsNullOrEmpty(workName))
????????????????????Console.WriteLine($“正在執(zhí)行?-->?{workName}“);

????????????????flag?=?func();

????????????????if?(!flag)
????????????????{
????????????????????if?(!string.IsNullOrEmpty(faildMessage))
????????????????????????Console.WriteLine(faildMessage);
????????????????????return?false;
????????????????}

????????????????if?(!string.IsNullOrEmpty(workName))
????????????????????Console.WriteLine($“結(jié)束執(zhí)行?-->?{workName}“);


????????????????Console.WriteLine(“...“);

????????????????return?flag;
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????Console.WriteLine(ex.Message);
????????????????return?false;
????????????}
????????}
????????public?void?Start()
????????{
????????????//更新
????????????Update();

????????????//重啟
????????????ReStart();


????????}

????????//更新
????????public?void?Update()
????????{
????????????Console.WriteLine(“***************開始更新****************“);

????????????//1.?檢查更新,獲取UpdateConfig.xml從而獲得需要新增,更新,刪除的工作清單?
????????????if?(!Work(CheckUpdate?“檢查更新“?“不需要更新“))?return;


????????????//2.?檢查更新文件數(shù)量
????????????if?(!Work(HasUpdateFiles?““?“沒有可更新的文件“))?return;


????????????//3.?如果程序已經(jīng)打開,進(jìn)程kill掉。
????????????if?(!Work(IsAppClose?“檢查應(yīng)用程序啟動狀態(tài)“?“未關(guān)閉應(yīng)用程序,更新停止“))?return;


????????????//4.?備份本地程序
????????????if?(!Work(BackUp?“備份程序“?“未能備份應(yīng)用程序,更新停止“))?return;


????????????//5.?開始更新,從任務(wù)清單獲取任務(wù)列表依次下載文件,然后執(zhí)行相關(guān)操作(增刪改)
????????????if?(Work(DoUpdate?“更新文件“?““))
????????????{
????????????????//6.1?為true時,更新本地版本號和更新時間

????????????????string?localConfig?=?$@“{ConfigurationManager.AppSettings[“LocalConfig“]}“;
????????????????xmlHelper.Update(localConfig?$“/AutoUpdater/UpdateInfo/Version“?“Num“?_model.Version);
????????????????xmlHelper.Update(localConfig?$“/AutoUpdater/UpdateInfo/UpdateTime“?“Date“?_model.UpdateTime);
????????????}
????????????else
????????????{
????????????????//6.2?為false時,還原本地程序
????????????????if?(!Work(ReBack?“系統(tǒng)還原“?“系統(tǒng)還原失敗“))?return;
????????????}


????????????//7.?刪除備份程序
????????????Work(DeleteBackFiles?“刪除備份文件“?“備份文件刪除失敗“);


????????????Console.WriteLine(“***************更新完畢!****************“);

????????}

????????//重新啟動
????????public?void?ReStart()
????????{
????????????if?(_

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-08-03?12:00??自動更新\
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\
?????文件?????????505??2018-08-03?11:50??自動更新\AutoUp\App.config
?????文件????????2478??2018-08-02?19:15??自動更新\AutoUp\AutoUp.csproj
?????文件???????15131??2018-08-03?12:00??自動更新\AutoUp\AutoUpdate.cs
?????文件?????????467??2018-08-03?10:40??自動更新\AutoUp\Program.cs
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\Properties\
?????文件????????1310??2018-08-02?14:04??自動更新\AutoUp\Properties\AssemblyInfo.cs
?????文件????????3547??2018-08-02?22:50??自動更新\AutoUp\UpdateConfigModel.cs
?????文件???????22718??2018-08-02?16:08??自動更新\AutoUp\xmlHelper.cs
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\bin\
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\bin\Debug\
?????文件???????19456??2018-08-03?12:00??自動更新\AutoUp\bin\Debug\AutoUp.exe
?????文件?????????505??2018-08-03?11:50??自動更新\AutoUp\bin\Debug\AutoUp.exe.config
?????文件???????46592??2018-08-03?12:00??自動更新\AutoUp\bin\Debug\AutoUp.pdb
?????目錄???????????0??2018-08-03?12:20??自動更新\AutoUp\bin\Debug\Download\
?????目錄???????????0??2018-08-03?12:20??自動更新\AutoUp\bin\Release\
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\obj\
?????目錄???????????0??2018-08-03?12:00??自動更新\AutoUp\obj\Debug\
?????文件?????????334??2018-08-03?12:00??自動更新\AutoUp\obj\Debug\AutoUp.csproj.FileListAbsolute.txt
?????文件????????2064??2018-08-03?12:00??自動更新\AutoUp\obj\Debug\AutoUp.csprojResolveAssemblyReference.cache
?????文件???????19456??2018-08-03?12:00??自動更新\AutoUp\obj\Debug\AutoUp.exe
?????文件???????46592??2018-08-03?12:00??自動更新\AutoUp\obj\Debug\AutoUp.pdb
?????文件??????????42??2018-08-02?19:06??自動更新\AutoUp\obj\Debug\CoreCompileInputs.cache
?????文件????????6690??2018-08-02?19:06??自動更新\AutoUp\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2018-08-03?12:20??自動更新\AutoUp\obj\Debug\TempPE\
?????文件?????????185??2018-08-02?18:38??自動更新\localconfig.xml
?????文件?????????746??2018-08-03?10:20??自動更新\updateconfig.xml
?????文件?????????905??2018-08-03?12:19??自動更新\使用說明.txt

評論

共有 條評論