Hey peps
I've just used this code to block a website
Imports System.IO
Public Class Form1
Dim path As String
Dim sw As StreamWriter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
path = "C:\Windows\System32\drivers\etc\hosts"
sw = New StreamWriter(path, True)
Dim Block As String = "\n 127.0.0.1 www.youporn.com"
sw.Write(Block)
sw.Close()
MsgBox("Site has been registered to system to be blocked", MsgBoxStyle.Information, Application.ProductName)
End Sub
End Class
how can I read the hosts file and remove the address that I've just registered because I can not delete the Host file like this.
My.Computer.FileSystem.DeleteFile("C:\Windows\System32\drivers\etc\hosts")
I want to read it inside and only remove the name I've just entered without interfearing with other names writen inside this file.