Enclose your code in a using clause.
This will call the Dispose method on the StreamWriter
class.
The Dispose
method calls the Flush
method, which writes to the stream.
Your code would look like this:
using (StreamWriter ofile =
new StreamWriter(@"C:\myPath\my_data_output.txt", true)
{
ofile.WriteLine(myString + "\t");
}
You can always call the flush method at any time.