I am making a game where I want to write to variables to text files to be able to store them. I have it set to read the file and what I want to happen is if the variable
clicks is greater than the value in the text file "clicks.txt" to replace the text there with the contents of the variable.
CODE
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim scoreReader As IO.StreamReader = IO.File.OpenText("clicks.txt")
Dim clickCount As Integer = scoreReader.ReadLine
If totalclicks > clickCount Then
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("clicks.txt", True)
file.WriteLine(clicks)
End If
End Sub
I know how to read files but can't really figure out how to write files. When I run this I get a IO Exception was unhandled message. Saying that the text file is being used but I'm certain that it isn't.
Edit: Also my text files are in the debug folder in bin.
Thanks
This post has been edited by chili5: 27 Jan, 2008 - 09:00 AM