Thanks for the link. It has what I want and now I'm using this:
CODE
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If File.Exists(Application.StartupPath & "\world.properties") Then 'Check if the file exists before doing things
Using reader As New StreamReader("world.properties")
'get the contents of the file
Dim contents As String = reader.ReadToEnd()
'insert the specified line
contents.Insert(2, Me.TextBox1.Text)
'now we need to rewrite the text in the file
Using writer As New StreamWriter("world.properties", False)
'write the file with the new line
writer.Write(contents)
End Using
End Using
Else
MsgBox("World.properties is not found")
End If
End Sub
But I keep getting an error saying world.properties is being used by another process.
Any help would be appreciated!
EDIT: Ok, well I sorta know why I get the error. It's in use twice so the second time is when it is getting the error. So I tried writing the edited file to world2.properties, and its just the same file. The edit isn't being made.
Any idea why? And I'd still like to have a better of editing the file instead of writing to a knew file, then deleting the original, then renaming the edited to the original's name xD
This post has been edited by animedude123: 20 Aug, 2008 - 08:34 PM