Simple question: StreamWriter
-
I wrote to a StreamWriter sitting on top of a NetworkStream, but calling Flush() didn't help get the data to the client. I understand that NetworkStream doesn't buffer and NetworkStream. Flush doesn't actually do anything - data written did not get flushed to client. But, it is StreamWriter.Flush() that I called. To resolve the problem, I just called Close on StreamWriter - which calls flush internally according to MSDN. Data is flushed to client side. Any idea? norm
-
I wrote to a StreamWriter sitting on top of a NetworkStream, but calling Flush() didn't help get the data to the client. I understand that NetworkStream doesn't buffer and NetworkStream. Flush doesn't actually do anything - data written did not get flushed to client. But, it is StreamWriter.Flush() that I called. To resolve the problem, I just called Close on StreamWriter - which calls flush internally according to MSDN. Data is flushed to client side. Any idea? norm
Actually, see the constructors for StreamWriter: they do buffer, and if you use Reflector, they use a default buffer size of 1024. Try creating a StreamWriter specifying a buffer size of 0, and see if it helps. You can do it on anything you choose - from .bat to .net - A customer
-
Actually, see the constructors for StreamWriter: they do buffer, and if you use Reflector, they use a default buffer size of 1024. Try creating a StreamWriter specifying a buffer size of 0, and see if it helps. You can do it on anything you choose - from .bat to .net - A customer
After you create the StreamWriter (but before using it) do the following:
myWriter.AutoFlush = true;
This seems to work for me Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989