public static bool ValidateSxGeo() { //проверяем наличие БД SxGeo SxPath = AddSlash(AddSlash(SettingsPath) + SxGeoDir) + SxGeoCity; IPGeoinfo tmpGeoInfo = new IPGeoinfo(SxPath); if (tmpGeoInfo.IsValidSxGeoFile()) //SxGeoSity найдена и валидная { SxGeoBase = SxGeoBaseType.SxGeoCity; return(true); } else { SxPath = AddSlash(AddSlash(SettingsPath) + SxGeoDir) + SxGeoCountry; tmpGeoInfo = new IPGeoinfo(SxPath); if (tmpGeoInfo.IsValidSxGeoFile()) //SxGeoCountry найдена и валидная { SxGeoBase = SxGeoBaseType.SxGeoCountry; return(true); } else { SxGeoBase = SxGeoBaseType.SxGeoNone; SxPath = string.Empty; return(false); } } }
private void btnUptateSxGeo_Click(object sender, EventArgs e) { DialogResult Ans = dlgOpenSxG.ShowDialog(); if (Ans == DialogResult.Cancel) { return; } string ResultMess = ""; string srcpath = CommonFunctions.AddSlash(dlgOpenSxG.SelectedPath) + CommonFunctions.SxGeoCountry; string dstpath = CommonFunctions.AddSlash(CommonFunctions.AddSlash( CommonFunctions.SettingsPath) + CommonFunctions.SxGeoDir) + CommonFunctions.SxGeoCountry; //ищем файл SxGeoCountry IPGeoinfo tmpGeoInfo = new IPGeoinfo(srcpath); if (tmpGeoInfo.IsValidSxGeoFile()) { ResultMess = "Файл " + CommonFunctions.SxGeoCountry + " найден. \n" + CommonFunctions.CopyFile(srcpath, dstpath) + "\n"; } else { ResultMess = "Файл " + CommonFunctions.SxGeoCountry + ": " + tmpGeoInfo.ErrorMessage + "\n"; } //ищем файл SxGeoCity srcpath = CommonFunctions.AddSlash(dlgOpenSxG.SelectedPath) + CommonFunctions.SxGeoCity; dstpath = CommonFunctions.AddSlash(CommonFunctions.AddSlash (CommonFunctions.SettingsPath) + CommonFunctions.SxGeoDir) + CommonFunctions.SxGeoCity; tmpGeoInfo = new IPGeoinfo(srcpath); if (tmpGeoInfo.IsValidSxGeoFile()) { ResultMess = ResultMess + "Файл " + CommonFunctions.SxGeoCity + " найден. \n" + CommonFunctions.CopyFile(srcpath, dstpath); } else { ResultMess = ResultMess + "Файл " + CommonFunctions.SxGeoCity + ": " + tmpGeoInfo.ErrorMessage; } CommonFunctions.ValidateSxGeo(); MessageBox.Show(ResultMess, "Результат обновления", MessageBoxButtons.OK, MessageBoxIcon.Information); }