BF2Statistics.HostsFile.Remove C# (CSharp) Method

Remove() public method

Removes a domain name from the hosts file
public Remove ( string Domain ) : bool
Domain string The domain name
return bool
        public bool Remove(string Domain)
        {
            if (Entries.ContainsKey(Domain))
            {
                Entries.Remove(Domain);
                return true;
            }

            return false;
        }

Usage Example

        /// <summary>
        /// Removes all gamespy related redirects in the specified hosts file container
        /// </summary>
        /// <param name="HostFile"></param>
        private static void RemoveRedirects(HostsFile HostFile)
        {
            // Remove Gamespy Addresses. Use a Bitwise OR here to execute both methods
            if (HostFile.Remove(Bf2StatsHost) | HostFile.RemoveAll(GamespyHosts))
            {
                // Save Changes
                HostFile.Save();

                // Flush the Cache of the gamespy hosts
                foreach (string host in GamespyHosts)
                {
                    DnsFlushResolverCacheEntry(host);
                }

                // Flush stats server
                DnsFlushResolverCacheEntry(Bf2StatsHost);
            }
        }
All Usage Examples Of BF2Statistics.HostsFile::Remove