首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# WINFORM 自动更新解决思路

2012-10-13 
C# WINFORM 自动更新C# WINFORM 自动更新使用的XML文件这个XML文件怎么设置呀!C# code[Description(应用

C# WINFORM 自动更新
C# WINFORM 自动更新使用的XML文件

这个XML文件怎么设置呀!

C# code
 
        [Description("应用程序文件URL")]
        public string AppFileURL
        {
            get
            {
                return this._AppFileURL;
            }
            set
            {
                this._AppFileURL = value;
            }
        }

        [DefaultValue(""), Description("应用程序路径。")]
        public string ApplicationPath
        {
            get
            {
                return this._applicationpath;
            }
            set
            {
                this._applicationpath = value;
            }
        }

        [Description("可用版本")]
        public string AvailableVersion
        {
            get
            {
                return this._AvailableVersion;
            }
            set
            {
                this._AvailableVersion = value;
            }
        }

        [Description("变更日志URL")]
        public string ChangeLogURL
        {
            get
            {
                return this._ChangeLogURL;
            }
            set
            {
                this._ChangeLogURL = value;
            }
        }

        [DefaultValue("http://localhost/UpdateConfig.xml"), Description("配置文件URL。(例如:http://localhost/UpdateConfig.xml)"), Category("自动更新配置")]
        public string ConfigURL
        {
            get
            {
                return this._ConfigURL;
            }
            set
            {
                this._ConfigURL = value;
            }
        }

        [Description("指定应用程序的当前版本"), Browsable(false)]
        public Version CurrentAppVersion
        {
            get
            {


                return Assembly.LoadFile(this.ApplicationPath + @"\" + this.EntryPoint).GetName().Version;
            }
        }

        [Description("指定应用程序的入口点")]
        public string EntryPoint
        {
            get
            {
                return this._entrypoint;
            }
            set
            {
                this._entrypoint = value;
            }
        }

        [Description("更新说明")]
        public string LatestChanges
        {
            get
            {
                return this._LatestChanges;
            }
            set
            {
                this._LatestChanges = value;
            }
        }

        [Browsable(false)]
        public string LatestConfigChanges
        {
            get
            {
                return this.LatestChanges;
            }
        }

        [Description("最新的配置文件版本"), Browsable(false)]
        public Version LatestConfigVersion
        {
            get
            {
                return new Version(this.AvailableVersion);
            }
        }

        [DefaultValue(""), Description("服务器端所需的登录名"), Category("自动更新配置")]
        public string LoginUserName
        {
            get
            {
                return this._LoginUserName;
            }
            set
            {
                this._LoginUserName = value;
            }
        }

        [Description("服务器端所需的登录密码"), Category("自动更新配置"), DefaultValue("")]
        public string LoginUserPass
        {
            get
            {
                return this._LoginUserPass;
            }
            set
            {
                this._LoginUserPass = value;
            }


        }

        [Description("是否有可用的新版本"), Browsable(false)]
        public bool NewVersionAvailable
        {
            get
            {
                return (this.LatestConfigVersion > this.CurrentAppVersion);
            }
        }

        [Description("选中的产品信息")]
        public DataRow ProductInformation
        {
            get
            {
                return this.mProductInformation;
            }
            set
            {
                this.mProductInformation = value;
            }
        }

        [Description("产品列表")]
        public DataTable ProductList
        {
            get
            {
                return this.mProductList;
            }
            set
            {
                this.mProductList = value;
            }
        }

        [Description("产品列表URL"), DefaultValue("http://www.flurrying.cn/ProductList.xml")]
        public string ProductListURL
        {
            get
            {
                return this.m_productListURL;
            }
            set
            {
                this.m_productListURL = value;
            }
        }

        [Description("是否启动代理"), Category("自动更新配置"), DefaultValue(false)]
        public bool ProxyEnabled
        {
            get
            {
                return this._ProxyEnabled;
            }
            set
            {
                this._ProxyEnabled = value;
            }
        }

        [DefaultValue(false), Description("代理服务器是否需要进行用户校验")]
        public bool ProxyEnableUserPassword
        {
            get
            {
                return this._proxyuserenable;
            }
            set
            {
                this._proxyuserenable = value;


            }
        }

        [Description("代理服务器密码")]
        public string ProxyPassword
        {
            get
            {
                return this._ProxyPwd;
            }
            set
            {
                this._ProxyPwd = value;
            }
        }

        [DefaultValue("http://myproxy.com:8080/"), Description("代理服务器URL(例如:http://myproxy.com:8080)"), Category("自动更新配置")]
        public string ProxyURL
        {
            get
            {
                return this._ProxyURL;
            }
            set
            {
                this._ProxyURL = value;
            }
        }

        [Description("代理服务器用户名")]
        public string ProxyUser
        {
            get
            {
                return this._ProxyUser;
            }
            set
            {
                this._ProxyUser = value;
            }
        }

        [Description("临时路径")]
        public string TempPath
        {
            get
            {
                return this._temppath;
            }
            set
            {
                this._temppath = value;
            }
        }

        [DefaultValue("update"), Description("ZIP文件名")]
        public string ZipFileName
        {
            get
            {
                return this._zipfilename;
            }
            set
            {
                this._zipfilename = value;
            }
        }



[解决办法]
做几点建议:
一、配置信息可以使用.config文件,因为提供了相关的类以便修改,这样就不用直接操作XML了。
二、自动更新的话,可以在后台使用一个线程去操作(如果配置文件更新很快的话),如果不是更新很快的话可以在程序每次启动的时候检测一下是否有最新版本的配置文件就可以了(可以在配置文件中添加一个节点表示当前版本号)。
------解决方案--------------------


同意楼上大哥的
[解决办法]
帮顶一下哦。
学习

热点排行