Exemplo n.º 1
0
        /// <summary>
        /// 加载配置文件到对象
        /// </summary>
        /// <param name="fileName">配置文件路径</param>
        /// <returns></returns>
        public static UpdateConfig LoadUpdateConfig(string fileName)
        {
            XmlSerializer xs     = new XmlSerializer(typeof(UpdateConfig));
            StreamReader  sr     = new StreamReader(fileName);
            UpdateConfig  config = xs.Deserialize(sr) as UpdateConfig;

            sr.Close();

            return(config);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="fileName">更新配置文件(全路径)</param>
 /// <param name="version">版本号</param>
 /// <param name="enterpriseCode">企业编号</param>
 /// <param name="address">服务器地址(IP地址+:+端口号)</param>
 public AutoUpdaterClient(string fileName, string version, string enterpriseCode, string address)
 {
     _mUpdateConfig    = UpdateConfig.LoadUpdateConfig(fileName);
     _UpdateConfigName = Path.GetFileName(fileName);
     if (!string.IsNullOrEmpty(version))
     {
         _Version = version;
     }
     _EnterpriseCode = enterpriseCode;
     _Address        = address;
 }
Exemplo n.º 3
0
 private void DealWithDownloadErrors()
 {
     try
     {
         //Test Network is OK or not.
         UpdateConfig config = UpdateConfig.LoadUpdateConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "update.config"));
         WebClient    client = new WebClient();
         client.DownloadString(config.ServerUrl);
     }
     catch (Exception)
     {
         //log the error message,you can use the application's log code
         ShowErrorAndRestartApplication();
     }
 }