-
大小: 796KB文件類型: .zip金幣: 2下載: 0 次發布日期: 2021-05-04
- 語言: C#
- 標簽: webservice??服務器端??自動升級??C#??
資源簡介
實現的通過webservice 獲取服務器端 程序實現 系統自動升級

代碼片段和文件信息
using?System;
using?System.Web;
using?System.IO;
using?System.Net;
using?System.xml;
using?System.Collections;
using?System.Windows.Forms;
using?System.ComponentModel;
namespace?AutoUpdate
{
///?
///?updater?的摘要說明。
///?
public?class?AppUpdater:IDisposable
{
#region?成員與字段屬性
private?string?_updaterUrl;
private?bool?disposed?=?false;
private?IntPtr?handle;
private?Component?component?=?new?Component();
[System.Runtime.InteropServices.DllImport(“Kernel32“)]
private?extern?static?Boolean?CloseHandle(IntPtr?handle);
public?string?UpdaterUrl
{
set{_updaterUrl?=?value;}
get{return?this._updaterUrl;}
}
#endregion
///?
///?AppUpdater構造函數
///?
public?AppUpdater()
{
this.handle?=?handle;
}
public?void?Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private?void?Dispose(bool?disposing)
{
if(!this.disposed)
{
if(disposing)
{
component.Dispose();
}
CloseHandle(handle);
handle?=?IntPtr.Zero;????????????
}
disposed?=?true;?????????
}
~AppUpdater()??????
{
Dispose(false);
}
///?
///?檢查更新文件
///?
///?lFile“>
///?lFile“>
///?
///?
public?int?CheckForUpdate(string?serverxmlFilestring?localxmlFileout?Hashtable?updateFileList)
{
updateFileList?=?new?Hashtable();
if(!File.Exists(localxmlFile)?||?!File.Exists(serverxmlFile))
{
return?-1;
}
xmlFiles?serverxmlFiles?=?new?xmlFiles(serverxmlFile);
xmlFiles?localxmlFiles?=?new?xmlFiles(localxmlFile);
xmlNodeList?newNodeList?=?serverxmlFiles.GetNodeList(“AutoUpdater/Files“);
xmlNodeList?oldNodeList?=?localxmlFiles.GetNodeList(“AutoUpdater/Files“);
int?k?=?0;
for(int?i?=?0;i? {
string?[]?fileList?=?new?string[3];
string?newFileName?=?newNodeList.Item(i).Attributes[“Name“].Value.Trim();
string?newVer?=?newNodeList.Item(i).Attributes[“Ver“].Value.Trim();
ArrayList?oldFileAl?=?new?ArrayList();
for(int?j?=?0;j? {
string?oldFileName?=?oldNodeList.Item(j).Attributes[“Name“].Value.Trim();
string?oldVer?=?oldNodeList.Item(j).Attributes[“Ver“].Value.Trim();
oldFileAl.Add(oldFileName);
oldFileAl.Add(oldVer);
}
int?pos?=?oldFileAl.IndexOf(newFileName);
if(pos?==?-1)
{
fileList[0]?=?newFileName;
fileList[1]?=?newVer;
updateFileList.Add(kfileList);
k++;
}
else?if(pos?>?-1?&&?newVer.CompareTo(oldFileAl[pos+1].ToString())>0?)
{
fileList[0]?=?newFileName;
fileList[1]?=?newVer;
updateFileList.Add(kfileList);
k++;
}
}
return?k;
}
///?
///?檢查更新文件
///?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-01-18?17:49??CsharpAutoUpdate\
?????目錄???????????0??2016-01-18?15:25??CsharpAutoUpdate\Backup\
?????目錄???????????0??2016-01-18?15:25??CsharpAutoUpdate\Backup\CsharpAutoUpdate\
?????文件?????????938??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate.sln
?????文件???????18944??2011-05-10?23:30??CsharpAutoUpdate\Backup\CsharpAutoUpdate.suo
?????文件????????5820??2011-05-10?23:11??CsharpAutoUpdate\Backup\CsharpAutoUpdate\AppUpdater.cs
?????文件????????3843??2011-05-10?22:46??CsharpAutoUpdate\Backup\CsharpAutoUpdate\CsharpAutoUpdate.csproj
?????文件????????9300??2011-05-10?23:30??CsharpAutoUpdate\Backup\CsharpAutoUpdate\FrmUpdate.cs
?????文件???????14064??2011-05-10?22:54??CsharpAutoUpdate\Backup\CsharpAutoUpdate\FrmUpdate.Designer.cs
?????文件??????109881??2011-05-10?22:54??CsharpAutoUpdate\Backup\CsharpAutoUpdate\FrmUpdate.resx
?????文件?????????501??2011-05-10?22:35??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Program.cs
?????目錄???????????0??2016-01-18?15:25??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\
?????文件????????1388??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\AssemblyInfo.cs
?????文件????????2882??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\Resources.Designer.cs
?????文件????????5612??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\Resources.resx
?????文件????????1101??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\Settings.Designer.cs
?????文件?????????249??2011-05-10?22:34??CsharpAutoUpdate\Backup\CsharpAutoUpdate\Properties\Settings.settings
?????文件????????1303??2011-05-10?23:11??CsharpAutoUpdate\Backup\CsharpAutoUpdate\xm
?????目錄???????????0??2011-05-10?23:30??CsharpAutoUpdate\CsharpAutoUpdate\
?????文件?????????938??2016-01-18?15:25??CsharpAutoUpdate\CsharpAutoUpdate.sln
?????文件???????26112??2016-01-18?21:28??CsharpAutoUpdate\CsharpAutoUpdate.suo
?????文件????????5816??2016-01-18?19:17??CsharpAutoUpdate\CsharpAutoUpdate\AppUpdater.cs
?????目錄???????????0??2016-01-18?15:25??CsharpAutoUpdate\CsharpAutoUpdate\bin\
?????目錄???????????0??2016-01-18?21:21??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\
?????文件???????18432??2016-01-18?19:24??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\CsharpAutoUpdate.exe
?????文件???????44544??2016-01-18?19:24??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\CsharpAutoUpdate.pdb
?????文件???????11608??2016-01-18?21:20??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\CsharpAutoUpdate.vshost.exe
?????文件?????????490??2015-10-30?15:19??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\CsharpAutoUpdate.vshost.exe.manifest
?????文件??????626688??2016-01-18?21:16??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\grproLib.dll
?????文件????????2065??2016-01-18?19:05??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\sscom.ini
?????文件??????626688??2016-01-18?21:16??CsharpAutoUpdate\CsharpAutoUpdate\bin\Debug\sscom42.exe
............此處省略37個文件信息
評論
共有 條評論