IO Stream URGENT HELP Please....

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Does anyone know how to send an IO stream to the browser? Preferably in a
new window.

Thanks in Advance.
 
Make a page that writes a stream to the Response.OutputStream, then
it's just a matter of linking to the page with target="_blank".

File stream example:

FileStream fs=new FileStream("path",FileMode.Open,FileAccess.Read);
try
{
byte[] buffer=new byte[1024];
int read=fs.Read(buffer,0,buffer.Length);
while(read>0)
{
Response.OutputStream.Write(buffer,0,read);
read=fs.Read(buffer,0,buffer.Length);
}
}
finally
{
fs.Close();
}

A note on using file content. Be sure to close the filestream,
otherwise it will be locked until you kill the IIS process, always use
try...finally. And, for security reasons, never send the path to read
from as POST or GET.

Cheers
Hugo
 
Would this work with code like this
stream = assem.GetManifestResourceStream(resourceName)

As the type of IO stream?
 
I am using an embedded resource(".aspx or .HTM") which is then extracted
from the for the Assembly like I have shown below.

stream = assem.GetManifestResourceStream(resourceName)

This stream I want to output to the browser in a open new window call
generated from the code behind.

Any help would be greatly appreciated.
 
Opening new windows is strictly client-side business. What you can do
is to register a startup script that opens the window for you using
window.open().

Embedding an aspx-file sounds like tricky business. Are you making
some kind of deployment tool? I suppose that it should be possible to
write the resource stream to a directory inside your web root and then
just link (hyperlink/window.open()) to it. Aspx-pages will be compiled
by IIS on the first request.

/Hugo
 
Back
Top