public void ReadICL() { try { if (!System.IO.Directory.Exists(ConfigDir)) { System.IO.Directory.CreateDirectory(ConfigDir); } ICList = LoadItemChangerList(ConfigPath); } catch (Exception ex) { Logger.Error("(ReadICL)", ex); } }
public static void CheckUpdate_Click() { try { string path = Properties.Settings.Default.UpdatePath; string xml = ""; if (path.ToLower().StartsWith(@"\\")) { StreamReader sr = new StreamReader(path); xml = sr.ReadToEnd(); } else if (path.ToLower().StartsWith("ftp") || path.ToLower().StartsWith("http")) { // Объект запроса HttpWebRequest rew = (HttpWebRequest)WebRequest.Create(path); // Отправить запрос и получить ответ HttpWebResponse resp = (HttpWebResponse)rew.GetResponse(); // Получить поток Stream str = resp.GetResponseStream(); // Выводим в TextBox int ch; string message = ""; for (int i = 1; ; i++) { ch = str.ReadByte(); if (ch == -1) { break; } message += (char)ch; } xml = message; // Закрыть поток str.Close(); } // Получить файл // Проверить версию // Оповестить string nverstring = gk.SQLConfigurator.ThisAddIn.LoadItemChangerList(path).CurrentVersion; if (!string.IsNullOrEmpty(nverstring)) { Version n = Version.Parse(nverstring); Version c = Version.Parse(ThisAddIn.ICList.CurrentVersion); if (n > c) { if (DialogResult.OK == MessageBox.Show(Properties.Resources.AvaibleNewConfigVersion, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { try { string dest = ThisAddIn.ConfigDir + DateTime.Now.ToString().Replace(":", string.Empty) + ThisAddIn.ConfigName + ".bak"; File.Copy(ThisAddIn.ConfigPath, dest); ThisAddIn.ICList = gk.SQLConfigurator.ThisAddIn.LoadItemChangerList(path); } catch (IOException copyError) { Logger.Error("(checkUpdate_Click_Copy_and_Update)", copyError); } } } } } catch (Exception ex) { Logger.Error("(checkUpdate_Click)", ex); } }