Public feed
#600324
using System.Diagnostics;
using System.Data;
using System.Collections;
using Microsoft.VisualBasic;
using System.Collections.Generic;
using System;
using System.IO;
namespace hostsfilecheck
{
sealed class Module1
{
static public void Main()
{
string HostsText = null;
string CheckHostsFile = "No";
using (StreamReader read = new StreamReader("C:\\windows\\system32\\drivers\\etc\\hosts"))
{
while (!read.EndOfStream)
{
HostsText = read.ReadLine().Trim();
if (HostsText.StartsWith("#") == false || string.IsNullOrEmpty(HostsText) == false)
{
if (HostsText.Contains("127.0.0.1") == false && HostsText.ToLower().Contains("localhost") == false)
{
Console.WriteLine(HostsText);
CheckHostsFile = "Yes";
}
}
}
read.Close();
}
Console.WriteLine("Has the hosts file more then the localhost entry? " + CheckHostsFile);
Console.ReadLine();
}
}
}