Guest User

Untitled

a guest
Nov 1st, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Net.Sockets;
  7. using System.Text;
  8.  
  9. namespace ConsoleApplication2
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             var hostfile = "";
  16.             var OSInfo = Environment.OSVersion;
  17.             string pathpart = "hosts";
  18.             if (OSInfo.Platform == PlatformID.Win32NT)
  19.             {
  20.                 //is windows NT
  21.                 pathpart = @"system32\drivers\etc\hosts";
  22.             }
  23.             hostfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), pathpart);
  24.  
  25.             if (!File.ReadAllLines(hostfile).Contains("123.123.123.123 download.talesrunner.com"))
  26.             {
  27.                 File.AppendAllLines(hostfile, new String[] { "123.123.123.123 download.talesrunner.com" });
  28.             }
  29.          
  30.             Console.ReadLine();
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment