酷文首页  
站内搜索:
网站地图 | RSS订阅 | 收藏本站
经济论文
证券金融
工商管理
会计审计
法学论文
医药论文
社会论文
教育论文
计算机论文
艺术论文
哲学论文
财政税收
财务管理
公共管理
理学论文
政治论文
文学论文
工学论文
文化论文
实用文档
应用文
自考成考
演讲稿
法律文书
子栏目导行↓
网站赞助商↓
本类热点↓
本类更新↓
热门标签↓
网摘收藏↓

利用Web Services实现软件自动升级

作者:曹庆旭
来源:论文网
点击:
载入中...
加入时间:2008-02-25
字体大小:[  ]
应用程序。这样更新就完成了。
       private void Form1_Load(object sender, System.EventArgs e)
       {
              System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses();
              foreach(System.Diagnostics.Process p in ps)
              {
                     //MessageBox.Show(p.ProcessName);
                     if(p.ProcessName.ToLower()=="customerapplication")
                     {
                            p.Kill();
                            break;
                     }
              }
              XmlDocument doc = new XmlDocument();
              doc.Load(Application.StartupPath + @"\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);
              for(int i=0;i= updateNode.ChildNodes[i];
                     string fileName = itemNode.Attributes["name"].Value;
                     FileInfo fi = new FileInfo(fileName);
                     fi.Delete();
                     //File.Delete(Application.StartupPath + @"\" + fileName);

                     this.label1.Text = "正在更新:" + fileName + " (" + itemNode.Attributes["size"].Value + ") ...";
                FileStream fs = File.Open(fileName,FileMode.Create,FileAccess.Write);    fs.Write(System.Convert.FromBase64String(itemNode.SelectSingleNode("value").InnerText),0,int.Parse(itemNode.Attributes["size"].Value));
               fs.Close();
            }
              label1.Text = "更新完成";
              File.Delete(Application.StartupPath + @"\update.xml");
              label1.Text = "正在重新启动应用程序...";
              System.Diagnostics.Process.Start("CustomerApplication.exe");
              Close();
              Application.Exit();
       }
这里为了简单起见,没有使用异步方法,当然使用异步方法能更好的避免并发调用产生的冲突,这个需要读者自己去添加。
4 结束语
借助Web Services实现软件的自动升级,不仅设计简单,实现起来也很容易,取得了良好的效应,大大减轻了维护的工作量。本方案具有较好的参考转贴于 酷文网-论文下载中心 http://www.coolwen.net


共4页: 上一页 [1] [2] 3 [4] 下一页

网摘收藏:
 -> 在百度中搜索:利用Web Services实现软件自动升级
 -> 在Google中搜索:利用Web Services实现软件自动升级
免责声明 | 关于我们 | 广告联系 | 友情链接 | 网站地图 | 共同合作
免费论文 毕业论文 毕业论文范文 酷文网(www.coolwen.net) 版权所有 coolwen.net 2007,All Rights Reserved
E-mail:hui_love#tom.com(为防止垃圾邮件请把#换成@) 点击这里给我发消息 点击这里给我发消息
湘ICP备07003917号