hello, firstly i am a complete beginner to vb.net.
My problem is i want to be able to write a url to a file. But there are a few problems.
First one is the file is "unknown" to windows. Its the windows host file. which has no extension.
second one is i need to write a line 21 lines down (making sure it does not over write any previously stored text. The line should look something like this
127.0.0.1 www.007guard.com
Can any one help me write this bit of code please. Iv searched gor ages for this but cant find it
her eis my code to get an idea
Thank you
My problem is i want to be able to write a url to a file. But there are a few problems.
First one is the file is "unknown" to windows. Its the windows host file. which has no extension.
second one is i need to write a line 21 lines down (making sure it does not over write any previously stored text. The line should look something like this
127.0.0.1 www.007guard.com
Can any one help me write this bit of code please. Iv searched gor ages for this but cant find it
her eis my code to get an idea
VB.NET:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add Version(s) to combo box
cmbVersion.Items.Add("Windows NT/2000/XP Pro")
cmbVersion.Items.Add("Windows XP Home")
cmbVersion.Items.Add("Windows 95/98/Me")
cmbVersion.Items.Add("Vista Home/Pro")
'Select second option as default
cmbVersion.SelectedIndex = 1
End Sub
Private Sub btnPatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPatch.Click
If cmbVersion.SelectedIndex = -1 Then
MsgBox("Stupid", MsgBoxStyle.Critical)
cmbVersion.Focus()
Else
If cmbVersion.SelectedIndex = 0 Then
'User slected xp pro
'Check file exists
If Dir("c:\winnt\system32\drivers\etc\hosts") <> "" Then
MsgBox("Patched")
Else
MsgBox("Can not Patch. File is missing", MsgBoxStyle.Critical)
End If
ElseIf cmbVersion.SelectedIndex = 1 Then
'User selected xp home
'Check file exist
If Dir("c:\windows\system32\drivers\etc\hosts") <> "" Then
MsgBox("Patched")
Else
MsgBox("Can not Patch. File is missing", MsgBoxStyle.Critical)
End If
ElseIf cmbVersion.SelectedIndex = 2 Then
'User selected 95/98/Me
'Check file exists
If Dir("c:\windows\hosts") <> "" Then
MsgBox("Patched")
Else
MsgBox("Can not Patch. File is missing", MsgBoxStyle.Critical)
End If
ElseIf cmbVersion.SelectedIndex = 3 Then
'User selected vista
'Check file exist
If Dir("C:\Windows\System32\Drivers\etc") <> "" Then
MsgBox("Patched")
Else
MsgBox("Can not Patch. File is missing", MsgBoxStyle.Critical)
End If
End If
End If
End Sub
Private Sub cmbVersion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbVersion.SelectedIndexChanged
End Sub
End Class
Thank you