XML文件
读取DownloadAddres 的值
<?xml version="1.0"?>
<AutoUpdater>
<DownloadAddres URL="http://6099.pqpq.net/UploadFiles/AutoUpdater.xml" />
<URLAddres URL="http://192.168.1.113/system/update/" />
<UpdateInfo>
<UpdateTime Date="2009-06-12" />
<Version Num="1.0.0.0" />
</UpdateInfo>
<UpdateFileList>
</UpdateFileList>
<RestartApp>
<ReStart Allow="Yes" />
<AppName Name="DownloadApp.exe" />
</RestartApp>
</AutoUpdater>
读取DownloadAddres 的值
public string GetDownloadAddres(string Dir)
{
string LastDownloadAddres = "";
string AutoUpdaterFileName = Dir;
if (!File.Exists(AutoUpdaterFileName))
{
return LastDownloadAddres;
}
//打开xml文件
FileStream myFile = new FileStream(AutoUpdaterFileName, FileMode.Open);
//xml文件阅读器
XmlTextReader xml = new XmlTextReader(myFile);
while (xml.Read())
{
if (xml.Name == "DownloadAddres")
{
//获取升级文档的最后一次更新日期
LastDownloadAddres = xml.GetAttribute("URL");
break;
}
}
xml.Close();
myFile.Close();
return LastDownloadAddres;
}