Application Help!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Application Help!!!

quochaiquochai Posts: 6Member
How do I output a stream to a text file? I wrote an http module to request a stream but now i want to output that to a text file. I know that I'll need to use response.outputstream. Any help is greatly appreciated.

Comments

  • weiccoweicco Posts: 950Member
    : How do I output a stream to a text file? I wrote an http module to request a stream but now i want to output that to a text file. I know that I'll need to use response.outputstream. Any help is greatly appreciated.
    :

    You got me confused. Do you want to write file as response? Response.WriteFile does that. Take notice that WriteFile doesn't work with large files, see MSDN documentation about that. But if you are writing somekind of download service you might want to return Content-Type, Content-Length and Content-Disposition HTTP headers also.

    But if you just want to write some stream to file, you'll have to read that stream into some temporary buffer and write that to file using FileStream.Write method. I suggest you not to read the whole stream at once into a buffer because that would waste a lot of memory in worst case, read it in chunks (and write it in chunks also).
  • quochaiquochai Posts: 6Member
    : : How do I output a stream to a text file? I wrote an http module to request a stream but now i want to output that to a text file. I know that I'll need to use response.outputstream. Any help is greatly appreciated.
    : :
    :
    : You got me confused. Do you want to write file as response? Response.WriteFile does that. Take notice that WriteFile doesn't work with large files, see MSDN documentation about that. But if you are writing somekind of download service you might want to return Content-Type, Content-Length and Content-Disposition HTTP headers also.
    :
    : But if you just want to write some stream to file, you'll have to read that stream into some temporary buffer and write that to file using FileStream.Write method. I suggest you not to read the whole stream at once into a buffer because that would waste a lot of memory in worst case, read it in chunks (and write it in chunks also).
    :
    Hey, thanks for replying.
    COuld you give me so codes to use? I would greatly appreciate it.

    Thanks
Sign In or Register to comment.