Using hostfile in C# I can block websites but I couldn't unblock them.
String path = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter sw = new StreamWriter(path, true);
sitetoblock = "\r\n127.0.0.1\t" + txtException.Text;
sw.Write(sitetoblock);
sw.Close();
MessageBox.Show(txtException.Text + " is blocked", "BLOCKED");
lbWebsites.Items.Add(txtException.Text);
txtException.Clear();
Here I need some help to unblock a specific site which is selected from listbox(lbWebsites). Is there a way to remove them from host file? I tried a lot and looked other solutions but something goes wrong in every solution.