C#实现程序的版本自动升级更新.docx

上传人:b****5 文档编号:7905689 上传时间:2023-01-27 格式:DOCX 页数:13 大小:23.34KB
下载 相关 举报
C#实现程序的版本自动升级更新.docx_第1页
第1页 / 共13页
C#实现程序的版本自动升级更新.docx_第2页
第2页 / 共13页
C#实现程序的版本自动升级更新.docx_第3页
第3页 / 共13页
C#实现程序的版本自动升级更新.docx_第4页
第4页 / 共13页
C#实现程序的版本自动升级更新.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

C#实现程序的版本自动升级更新.docx

《C#实现程序的版本自动升级更新.docx》由会员分享,可在线阅读,更多相关《C#实现程序的版本自动升级更新.docx(13页珍藏版)》请在冰豆网上搜索。

C#实现程序的版本自动升级更新.docx

C#实现程序的版本自动升级更新

我们做了程序,不免会有版本升级,这就需要程序有自动版本升级的功能。

那么看看我是如何实现程序自动更新的。

直接上代码:

​1u​s​i​n​g​S​y​s​t​e​m​;​​​​

​2u​s​i​n​g​S​y​s​t​e​m​.​C​o​l​l​e​c​t​i​o​n​s​.​G​e​n​e​r​i​c​;​​​​

​3u​s​i​n​g​S​y​s​t​e​m​.​T​e​x​t​;​​​​

​4u​s​i​n​g​S​y​s​t​e​m​.​R​e​f​l​e​c​t​i​o​n​;​​​​

​5u​s​i​n​g​S​y​s​t​e​m​.​I​O​;​​​​

​6u​s​i​n​g​S​y​s​t​e​m​.​N​e​t​;​​​​

​7u​s​i​n​g​S​y​s​t​e​m​.​X​m​l​;​​​​

​8​​​

​9n​a​m​e​s​p​a​c​e​U​p​d​a​t​e​​​​

1​0​{​​​​

1​1​​​​/​/​/<​s​u​m​m​a​r​y​>​​

1​2​​​​/​/​/​更​新​完​成​触​发​的​事​件​​​

1​3​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

1​4​​​​p​u​b​l​i​cd​e​l​e​g​a​t​ev​o​i​d​U​p​d​a​t​e​S​t​a​t​e​(​)​;​​​​

1​5​​​​/​/​/<​s​u​m​m​a​r​y​>​​

1​6​​​​/​/​/​程​序​更​新​​​

1​7​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

1​8​​​​p​u​b​l​i​cc​l​a​s​s​S​o​f​t​U​p​d​a​t​e​​​​

1​9​​​​​{​​​​

2​0​​​

2​1​​​​​​​​p​r​i​v​a​t​es​t​r​i​n​g​d​o​w​n​l​o​a​d​;​​​​

2​2​​​​​​​​p​r​i​v​a​t​ec​o​n​s​ts​t​r​i​n​g​u​p​d​a​t​e​U​r​l​="h​t​t​p​:

​/​/​w​w​w​.​c​s​d​n​.​n​e​t​/​u​p​d​a​t​e​.​x​m​l";/​/升​级​配​置​的​X​M​L​文​件​地​址​​

2​3​​

2​4​​​​​​​​#​r​e​g​i​o​n​构​造​函​数​​​

2​5​​​​​​​​p​u​b​l​i​c​S​o​f​t​U​p​d​a​t​e​(​)​​{​​}​​​​

2​6​​​

2​7​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

2​8​​​​​​​​/​/​/​程​序​更​新​​​

2​9​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

3​0​​​​​​​​/​/​/<​p​a​r​a​m​​n​a​m​e​=​"​f​i​l​e​"​>要​更​新​的​文​件<​/​p​a​r​a​m​>​​

3​1​​​​​​​​p​u​b​l​i​c​S​o​f​t​U​p​d​a​t​e​(s​t​r​i​n​g​f​i​l​e​,s​t​r​i​n​g​s​o​f​t​N​a​m​e​)​​{​​​​

3​2​​​​​​​​​​​​t​h​i​s.​L​o​a​d​F​i​l​e​=​f​i​l​e​;​​​​

3​3​​​​​​​​​​​​t​h​i​s.​S​o​f​t​N​a​m​e​=​s​o​f​t​N​a​m​e​;​​​​

3​4​​​​​​​​​}​​​​

3​5​​​​​​​​#​e​n​d​r​e​g​i​o​n​

3​6​​

3​7​​​​​​​​#​r​e​g​i​o​n​属​性​​​

3​8​​​​​​​​p​r​i​v​a​t​es​t​r​i​n​g​l​o​a​d​F​i​l​e​;​​​​

3​9​​​​​​​​p​r​i​v​a​t​es​t​r​i​n​g​n​e​w​V​e​r​s​o​n​;​​​​

4​0​​​​​​​​p​r​i​v​a​t​es​t​r​i​n​g​s​o​f​t​N​a​m​e​;​​​​

4​1​​​​​​​​p​r​i​v​a​t​eb​o​o​l​i​s​U​p​d​a​t​e​;​​​​

4​2​​​

4​3​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

4​4​​​​​​​​/​/​/​或​取​是​否​需​要​更​新​​​

4​5​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

4​6​​​​​​​​p​u​b​l​i​cb​o​o​l​I​s​U​p​d​a​t​e​​​​

4​7​​​​​​​​​{​​​​

4​8​​​​​​​​​​​​g​e​t​​​​

4​9​​​​​​​​​​​​​{​​​​

5​0​​​​​​​​​​​​​​​​​c​h​e​c​k​U​p​d​a​t​e​(​)​;​​​​

5​1​​​​​​​​​​​​​​​​r​e​t​u​r​n​i​s​U​p​d​a​t​e​;​​​​​

5​2​​​​​​​​​​​​​}​​​​

5​3​​​​​​​​​}​​​​

5​4​​​

5​5​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

5​6​​​​​​​​/​/​/​要​检​查​更​新​的​文​件​​​

5​7​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

5​8​​​​​​​​p​u​b​l​i​cs​t​r​i​n​g​L​o​a​d​F​i​l​e​​​​

5​9​​​​​​​​​{​​​​

6​0​​​​​​​​​​​​g​e​t​{​r​e​t​u​r​n​l​o​a​d​F​i​l​e​;​​}​​​​

6​1​​​​​​​​​​​​s​e​t​{​​l​o​a​d​F​i​l​e​=​v​a​l​u​e​;​​}​​​​

6​2​​​​​​​​​}​​​​

6​3​​​

6​4​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

6​5​​​​​​​​/​/​/​程​序​集​新​版​本​​​

6​6​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

6​7​​​​​​​​p​u​b​l​i​cs​t​r​i​n​g​N​e​w​V​e​r​s​o​n​​​​

6​8​​​​​​​​​{​​​​

6​9​​​​​​​​​​​​g​e​t​{​r​e​t​u​r​n​n​e​w​V​e​r​s​o​n​;​​}​​​​

7​0​​​​​​​​​}​​​​

7​1​​​

7​2​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

7​3​​​​​​​​/​/​/​升​级​的​名​称​​​

7​4​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

7​5​​​​​​​​p​u​b​l​i​cs​t​r​i​n​g​S​o​f​t​N​a​m​e​​​​

7​6​​​​​​​​​{​​​​

7​7​​​​​​​​​​​​g​e​t​{​r​e​t​u​r​n​s​o​f​t​N​a​m​e​;​​}​​​​

7​8​​​​​​​​​​​​s​e​t​{​​s​o​f​t​N​a​m​e​=​v​a​l​u​e​;​​}​​​​

7​9​​​​​​​​​}​​​

8​0​​

8​1​​​​​​​​#​e​n​d​r​e​g​i​o​n​​

8​2​​​

8​3​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

8​4​​​​​​​​/​/​/​更​新​完​成​时​触​发​的​事​件​​​

8​5​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

8​6​​​​​​​​p​u​b​l​i​ce​v​e​n​t​U​p​d​a​t​e​S​t​a​t​e​​U​p​d​a​t​e​F​i​n​i​s​h​;​​​​

8​7​​​​​​​​p​r​i​v​a​t​ev​o​i​d​i​s​F​i​n​i​s​h​(​)​​{​​​​

8​8​​​​​​​​​​​​i​f(​U​p​d​a​t​e​F​i​n​i​s​h​!

​=n​u​l​l)​​​​

8​9​​​​​​​​​​​​​​​​​U​p​d​a​t​e​F​i​n​i​s​h​(​)​;​​​​

9​0​​​​​​​​​}​​​​

9​1​​​

9​2​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

9​3​​​​​​​​/​/​/​下​载​更​新​​​

9​4​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

9​5​​​​​​​​p​u​b​l​i​cv​o​i​d​U​p​d​a​t​e​(​)​​​​

9​6​​​​​​​​​{​​​​

9​7​​​​​​​​​​​​t​r​y​​

9​8​​​​​​​​​​​​​{​​​​

9​9​​​​​​​​​​​​​​​​i​f​(!

i​s​U​p​d​a​t​e​)​​​​

1​0​0​​​​​​​​​​​​​​​​​​​​r​e​t​u​r​n;​​​​

1​0​1​​​​​​​​​​​​​​​​​W​e​b​C​l​i​e​n​t​​w​c​=n​e​w​W​e​b​C​l​i​e​n​t​(​)​;​​​​

1​0​2​​​​​​​​​​​​​​​​s​t​r​i​n​g​f​i​l​e​n​a​m​e​="​";​​​​

1​0​3​​​​​​​​​​​​​​​​s​t​r​i​n​g​e​x​t​e​n​=​d​o​w​n​l​o​a​d​.​S​u​b​s​t​r​i​n​g​(​d​o​w​n​l​o​a​d​.​L​a​s​t​I​n​d​e​x​O​f​(".")​)​;​​​​

1​0​4​​​​​​​​​​​​​​​​i​f​(​l​o​a​d​F​i​l​e​.​I​n​d​e​x​O​f​(@​"\")​=​=-1)​​​​

1​0​5​​​​​​​​​​​​​​​​​​​​​f​i​l​e​n​a​m​e​="U​p​d​a​t​e​_"+​P​a​t​h​.​G​e​t​F​i​l​e​N​a​m​e​W​i​t​h​o​u​t​E​x​t​e​n​s​i​o​n​(​l​o​a​d​F​i​l​e​)​+​e​x​t​e​n​;​​​​

1​0​6​​​​​​​​​​​​​​​​e​l​s​e​​

1​0​7​​​​​​​​​​​​​​​​​​​​​f​i​l​e​n​a​m​e​=​P​a​t​h​.​G​e​t​D​i​r​e​c​t​o​r​y​N​a​m​e​(​l​o​a​d​F​i​l​e​)​+"\​\​U​p​d​a​t​e​_"+​P​a​t​h​.​G​e​t​F​i​l​e​N​a​m​e​W​i​t​h​o​u​t​E​x​t​e​n​s​i​o​n​(​l​o​a​d​F​i​l​e​)​+​e​x​t​e​n​;​​​​

1​0​8​​​​​​​​​​​​​​​​​w​c​.​D​o​w​n​l​o​a​d​F​i​l​e​(​d​o​w​n​l​o​a​d​,​​f​i​l​e​n​a​m​e​)​;​​​​

1​0​9​​​​​​​​​​​​​​​​​w​c​.​D​i​s​p​o​s​e​(​)​;​​​​

1​1​0​​​​​​​​​​​​​​​​​i​s​F​i​n​i​s​h​(​)​;​​​​

1​1​1​​​​​​​​​​​​​}​​​​

1​1​2​​​​​​​​​​​​c​a​t​c​h​​

1​1​3​​​​​​​​​​​​​{​​​​

1​1​4​​​​​​​​​​​​​​​​t​h​r​o​wn​e​w​E​x​c​e​p​t​i​o​n​("更​新​出​现​错​误​,​网​络​连​接​失​败​!

")​;​​​​

1​1​5​​​​​​​​​​​​​}​​​​

1​1​6​​​​​​​​​}​​​​

1​1​7​​​

1​1​8​​​​​​​​/​/​/<​s​u​m​m​a​r​y​>​​

1​1​9​​​​​​​​/​/​/​检​查​是​否​需​要​更​新​​​

1​2​0​​​​​​​​/​/​/<​/​s​u​m​m​a​r​y​>​​

1​2​1​​​​​​​​p​u​b​l​i​cv​o​i​d​c​h​e​c​k​U​p​d​a​t​e​(​)​​​​​

1​2​2​​​​​​​​​{​​​​

1​2​3​​​​​​​​​​​​t​r​y​{​​​​

1​2​4​​​​​​​​​​​​​​​​​W​e​b​C​l​i​e​n​t​​w​c​=n​e​w​W​e​b​C​l​i​e​n​t​(​)​;​​​​

1​2​5​​​​​​​​​​​​​​​​​S​t​r​e​a​m​​s​t​r​e​a​m​=​w​c​.​O​p​e​n​R​e​a​d​(​u​p​d​a​t​e​U​r​l​)​;​​​​

1​2​6​​​​​​​​​​​​​​​​​X​m​l​D​o​c​u​m​e​n​t​​x​m​l​D​o​c​=n​e​w​X​m​l​D​o​c​u​m​e​n​t​(​)​;​​​​

1​2​7​​​​​​​​​​​​​​​​​x​m​l​D​o​c​.​L​o​a​d​(​s​t​r​e​a​m​)​;​​​​

1​2​8​​​​​​​​​​​​​​​​​X​m​l​N​o​d​e​​l​i​s​t​=​x​m​l​D​o​c​.​S​e​l​e​c​t​S​i​n​g​l​e​N​o​d​e​("U​p​d​a​t​e")​;​​​​

1​2​9​​​​​​​​​​​​​​​​f​o​r​e​a​c​h(​X​m​l​N​o​d​e​​n​o​d​e​i​n​l​i​s​t​)​​{​​​​

1​3​0​​​​​​​​​​​​​​​​​​​​i​f(​n​o​d​e​.​N​a​m​e​=​="S​o​f​t"&​&​n​o​d​e​.​A​t​t​r​i​b​u​t​e​s​["N​a​m​e"]​.​V​a​l​u​e​.​T​o​L​o​w​e​r​(​)​=​=​S​o​f​t​N​a​m​e​.​T​o​L​o​w​e​r​(​)​)​​{​​​​

1​3​1​​​​​​​​​​​​​​​​​​​​​​​​f​o​r​e​a​c​h(​X​m​l​N​o​d​e​​x​m​l​i​n​n​o​d​e​)​​{​​​​

1​3​2​​​​​​​​​​​​​​​​​​​​​​​​​​​​i​f(​x​m​l​.​N​a​m​e​=​="V​e​r​s​o​n")​​​​

1​3​3​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​n​e​w​V​e​r​s​o​n​=​x​m​l​.​I​n​n​e​r​T​e​x​t​;​​​​

1​3​4​​​​​​​​​​​​​​​​​​​​​​​​​​​​e​l​s​e​​

1​3​5​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​d​o​w​n​l​o​a​d​=​x​m​l​.​I​n​n​e​r​T​e​x​t​;​​​​

1​3​6​​​​​​​​​​​​​​​​​​​​​​​​​}​​​​

1​3​7​​​​​​​​​​​​​​​​​​​​​}​​​​

1​3​8​​​​​​​​​​​​​​​​​}​​​​

1​3​9​​​

1​4​0​​​​​​​​​​​​​​​​​V​e​r​s​i​o​n​​v​e​r​=n​e​w​V​e​r​s​i​o​n​(​n​e​w​V​e​r​s​o​n​)​;​​​​

1​4​1​​​​​​​​​​​​​​​​​V​e​r​s​i​o​n​​v​e​r​s​o​n​=​A​s​s​e​m​b​l​y​.​L​o​a​d​F​r​o​m​(​l​o​a​d​F​i​l​e​)​.​G​e​t​N​a​m​e​(​)​.​V​e​r​s​i​o​n​;​​​​

1​4​2​​​​​​​​​​​​​​​​i​n​t​t​m​=​v​e​r​s​o​n​.​C​o​m​p​a​r​e​T​o​(​v​e​r​)​;​​​​

1​4​3​​​

1​4​4​​​​​​​​​​​​​​​​i​f(​t​m​>​=0)​​​​

1​4​5​​​​​​​​​​​​​​​​​​​​​i​s​U​p​d​a​t​e​=f​a​l​s​e;​​​​

1​4​6​​​​​​​​​​​​​​​​e​l​s​e​​

1​4​7​​​​​​​​​​​​​​​​​​​​​i​s​U​p​d​a​t​e​=t​r​u​e;​​​​

1​4​8​​​​​​​​​​​​​}​​​​

1​4​9​​​​​​​​​​​​c​a​t​c​h(​E​x​c​e​p​t​i​o​n​​e​x​)​​{​​​​

1​5​0​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​t​h​r​o​wn​e​w​E​x​c​e​p​t​i​o​n​("更​新​出​现​错​误​,​请​确​认​网​络​连​接​无​误

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 工学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1