StreamWriter leaving txt file empty!

eddy556

Member
Joined
May 14, 2007
Messages
11
Programming Experience
1-3
Take a look at this code:

VB.NET:
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
 
If System.IO.File.Exists(filename) = False Then
 
oWrite = IO.File.CreateText(filename)
 
oWrite.WriteLine("hello")
 
MsgBox("File has been created!")
End If
it is successfully creating the file using 'filename' which is passed to the sub from the form, but is leaving it empty...where I'd expect the word 'hello' to be on the first line.

I know there is probably something really obviously wrong here...thanks for your help! :)
 
Last edited by a moderator:
Close the file: oWrite.Close()
 
Back
Top