Reputation: 6368
I am trying to write some text at the end of the file.
Here is my code
Dim Writer As System.IO.StreamWriter = IO.File.AppendText("D:\Vishal.txt")
Writer.WriteLine("I am Vishal")
But I am not getting anything in the above mentioned file. Also there are no errors in the program.
Upvotes: 1
Views: 1473
Reputation: 460138
You have to flush the stream to write it's buffer, you could call writer.Flush
, writer.Close
or use the using
-statement what is best practise anyway when using disposable objects:
Using Writer As System.IO.StreamWriter = IO.File.AppendText("D:\Vishal.txt")
Writer.WriteLine("I am Vishal")
End Using
That works because a StreamWriter
gets closed implicitely before it's disposed.
Upvotes: 5