Re: Serve up file from outside web application directory
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Fri, 24 Aug 2007 02:21:07 GMT
Thanks for your followup Brian,
for the text file with "System.Byte[]" problem you mentioned, do you mean
the file download dialog display the filename as "System.Byte[]"?
If this is the case, I suggest you check the code to see whether you have
add the "Content-Disposition" header and supply the filename. Because when
you stream out a file(or other binary content), the ASP.Net won't care
what's their original filename, you need to explicitly supply them.e.g.
======================
protected void Page_Load(object sender, EventArgs e)
{
byte[] bytes = null;
string path = @"d:\filestore\pdf_files\test.pdf";
bytes = File.ReadAllBytes(path);
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType= "text/plain";
//here put the filename
Response.AddHeader("Content-disposition", "attachment;
filename=test.txt");
Response.Write(bytes);
Response.End();
}
===========
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: Serve up file from outside web application directory
- From: Brian Simmons
- Re: Serve up file from outside web application directory
- References:
- Serve up file from outside web application directory
- From: Brian Simmons
- Re: Serve up file from outside web application directory
- From: Aidy
- Re: Serve up file from outside web application directory
- From: Aidy
- Re: Serve up file from outside web application directory
- From: Steven Cheng[MSFT]
- Re: Serve up file from outside web application directory
- From: Brian Simmons
- Serve up file from outside web application directory
- Prev by Date: Dotfuscator problem
- Next by Date: Re: fire a VBS from ASP.NET
- Previous by thread: Re: Serve up file from outside web application directory
- Next by thread: Re: Serve up file from outside web application directory
- Index(es):
Relevant Pages
|