try this.
private void button1_Click(object sender, EventArgs e)
{
String path = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter sw = new StreamWriter(path, true);
String sitetoblock = "\n 127.0.0.1 Your_url_for_blocking";
sw.Write(sitetoblock);
sw.Close();
}