62,046
社区成员
发帖
与我相关
我的任务
分享
[WebMethod(Description = "在线更新软件")]
public System.Xml.XmlDocument GetUpdateData()
{
//取得更新的xml模板内容
XmlDocument doc = new XmlDocument();
//处理操作
return doc;
}
[WebMethod(Description = "在线更新软件")]
public System.Xml.XmlDocument GetUpdateData()
{
//取得更新的xml模板内容
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("update.xml"));
XmlElement root = doc.DocumentElement;
//看看有几个文件需要更新
XmlNode updateNode = root.SelectSingleNode("filelist");
string path = updateNode.Attributes["sourcepath"].Value;
int count = int.Parse(updateNode.Attributes["count"].Value);
//将xml中的value用实际内容替换
for (int i = 0; i < count; i++)
{
XmlNode itemNode = updateNode.ChildNodes[i];
string fileName = path + itemNode.Attributes["name"].Value;
FileStream fs = File.OpenRead(Server.MapPath(fileName));
itemNode.Attributes["size"].Value = fs.Length.ToString();
BinaryReader br = new BinaryReader(fs);
//这里是文件的实际内容,使用了Base64String编码
itemNode.SelectSingleNode("value").InnerText =
Convert.ToBase64String(br.ReadBytes((int)fs.Length), 0, (int)fs.Length);
br.Close();
fs.Close();
}
return doc;
}