Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Simple question: StreamWriter

Simple question: StreamWriter

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devvvy
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • D devvvy

      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

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • D Daniel Turini

        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

        T Offline
        T Offline
        Tatham
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups