private void btnRestoreDefaults_Click(object sender, EventArgs e) { _dnsProviders.Clear(); _dnsProviders.AddRange(DnsProvider.GetDefaultProviders()); RefreshDnsProvidersList(); ClearForm(); }
private void LoadConfig() { try { using (FileStream fS = new FileStream(_configFile, FileMode.Open, FileAccess.Read)) { BinaryReader bR = new BinaryReader(fS); if (Encoding.ASCII.GetString(bR.ReadBytes(2)) != "DT") { throw new InvalidDataException("Invalid DNS Server System Tray App config file format."); } switch (bR.ReadByte()) { case 1: int count = bR.ReadInt32(); _dnsProviders.Clear(); for (int i = 0; i < count; i++) { _dnsProviders.Add(new DnsProvider(bR)); } _dnsProviders.Sort(); break; default: throw new NotSupportedException("DNS Server System Tray App config file format is not supported."); } } } catch (FileNotFoundException) { _dnsProviders.Clear(); _dnsProviders.AddRange(DnsProvider.GetDefaultProviders()); _dnsProviders.Sort(); } catch (Exception ex) { MessageBox.Show("Error occured while loading config file. " + ex.Message, "Error - " + Resources.ServiceName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }