引入Microsoft.VisualBasic這個程序集
然後在命名空間中引用 Microsoft.VisualBasic.Devices
這樣就可以實現現在遠程文件到本地 然後進行對比....
下面代碼基本意思就是:
* 已知了當前的版本號
* 然後下載遠程程序版本文件到本地
* 對比當前版本與已下載版本號碼
* 如果當前版本低 那麼開始執行指定的命令
//當前版本號
String nowVersion="8.0";
//定義文件下載地址
String fileUrl="http://127.0.0.1/DownloadVersion.aspx";
//存儲文件名
String filePath=Request.PhysicalApplicationPath+ "version.xml";
//實例網絡交互對象
Network network=new Computer()
//開始下載
network.DownloadFile(fileUrl, filePath);
//實例Xml對象並加載已下載文件
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
//創建遊標
XPathNavigator navigator = doc.CreateNavigator();
//獲取當前版本號
Int32 version =Int32.Parse(navigator.SelectSingleNode("/AppVersion/AppVersion[last()]").Value);
if(nowVersion<version)
{
Response.Write("請geng新nin的wang站!dao"+version+"版本");
}