Re: IO Stream HELP URGENT!!!
From: Dennis Myrén (dennis_at_oslokb.no)
Date: 03/24/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Sharing code possible-ASP.NET and Windows Forms"
- Previous message: Daniel Jin: "Re: Sharing code possible-ASP.NET and Windows Forms"
- In reply to: Chris: "Re: IO Stream HELP URGENT!!!"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 16:57:56 +0100
If your System.IO.Stream is a System.IO.MemoryStream you can just call
Response.BinaryWrite(memoryStream.ToArray());
If it is not, maybe the object you want to output provides
a method for saving to a System.IO.Stream, like System.Drawing.Image does;
then you can just do this:
myImage.Save(Response.OutputStream);
If not, do:
(where "stream" variable represent the System.IO.Stream instance you want to
output):
byte [] data = new byte [stream.Length];
stream.Read(data, 0x0, data.Length);
Response.BinaryWrite(data);
This will fill a byte array with the content of "stream" and write to the
response output stream.
Note; always clear the response before writing binary data,
otherwise the binary data might get corrupted.
Do this by calling
Response.Clear();
Response.ClearContent();
prior to the binary write operation.
Also, you should provide information about the content type of the binary
data that will be written
to the response object, eg:
Response.ContentType = "image/png";
if it is a PNG binary stream.
Regards, Dennis
"Chris" <calhoun_chris@hotmail.com> wrote in message
news:e3mFg3aEEHA.576@TK2MSFTNGP11.phx.gbl...
> Response.BinaryWrite does not accept a stream data type.
> Can you provide an example of how to use OutPutStream in this way?
> "Dennis Myrén" <dennis@oslokb.no> wrote in message
> news:pHg8c.2683$px6.38412@news2.e.nsc.no...
> >
> > use Response.BinaryWrite
> > or Response.OutputStream
> >
> > "Chris" <calhoun_chris@hotmail.com> wrote in message
> > news:ufaCRkaEEHA.2968@TK2MSFTNGP12.phx.gbl...
> > > Does anyone know how to send an IO stream to the browser? Preferably
in
> a
> > > new window.
> > >
> > > Thanks in Advance.
> > >
> > >
> >
> >
>
>
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Sharing code possible-ASP.NET and Windows Forms"
- Previous message: Daniel Jin: "Re: Sharing code possible-ASP.NET and Windows Forms"
- In reply to: Chris: "Re: IO Stream HELP URGENT!!!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|