Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- var hostfile = "";
- var OSInfo = Environment.OSVersion;
- string pathpart = "hosts";
- if (OSInfo.Platform == PlatformID.Win32NT)
- {
- //is windows NT
- pathpart = @"system32\drivers\etc\hosts";
- }
- hostfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), pathpart);
- if (!File.ReadAllLines(hostfile).Contains("123.123.123.123 download.talesrunner.com"))
- {
- File.AppendAllLines(hostfile, new String[] { "123.123.123.123 download.talesrunner.com" });
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment