View difference between Paste ID: Yz1ahPd0 and f9Y0fCR2
SHOW: | | - or go back to the newest paste.
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";
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
}