/// <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; }
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(); } }