« Run X windows on Windows with Cygwin | Main | Australia plans to outlaw incandescent bulbs and switch to fluorescents »
Move data from one stream to another

PumpStream is a handy C# static method for moving (or "pumping") all the bytes from one stream to another.

It's helpful when you want to move data from a FileStream into a DeflateStream, for example. Another good use is streaming data from a MemoryStream or FileStream to a client via ASP.NET's Response.OutputStream property.

Since PumpStream uses a configurable size intermediate buffer, you're never going to run out of memory no matter how much data you're pumping.

See the code and download it here.

Posted by JoshC at February 19, 2007 8:15 PM
Trackbacks
TrackBack URL for this entry:
http://www.joshchristie.com/weblog/mt/mt-tb.cgi/168

Listed below are links to weblogs that reference 'Move data from one stream to another' from Josh Christie's Weblog.
Comments
Post a comment









Remember personal info?