Search:
Namespaces
Discussions
.NET v1.1
Feedback
Automatically Start Download
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngfreeforall' list
.
Gavin
Hi All,
I think this is a simple question really.
I have an application that exports my crystal reports to .pdf and saves them
on my server, what I would like to do now is to begin an automatic download
of this file to the client but can't seem to get that to work.
If I just point the clients browser at the file then it just opens it, I
don't want this I want it to come up and ask them where they wish to save
it.
I hope this is a simple answer :).
Thanks,
Gavin
Reply to this message...
Tim
This works fine for me:
try
{
String FileName =3D SavePDF();
Response.Clear();
Response.Buffer =3D true;
// if export to PDF
if (ExportList.SelectedIndex =3D=3D 0)
{
Response.AddHeader("Content-Type","application/pdf");
Response.AddHeader("Content-Disposition","attachment;filename=3D" + =
"orderlist.pdf" + ";");
}
// else export to Excel
else
{
Response.AddHeader("Content-Type","application/xls");
Response.AddHeader("Content-Disposition","attachment;filename=3D" + =
"orderlist.xls" + ";");
}
FileStream Fs =3D new
FileStream
(FileName,
FileMode
.Open);
long FileSize =3D Fs.Length;
byte[] bBuffer =3D new
Byte
[FileSize];
Fs.Read(bBuffer,0,
Convert
.ToInt32(FileSize));
Fs.Close();
Response.BinaryWrite(bBuffer);
Response.Flush();
Response.Close();
}
If you are using PDF, you should only watch the first case: =
Response.AddHeader("Content-Type","application/pdf");
Best Regards,
Tim Musschoot
AspFriends Moderation Team
----- Original Message -----
From: Gavin <
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 16 Aug 2002 10:15:46 +0100
Subject: Automatically Start Download
[Original message clipped]
Reply to this message...
Gavin
Thanks a million, that works perfectly.
I'm glad it wasn't totally obvious, I don't feel that dumb anymore..
Cheers,
Gavin
[Original message clipped]
Reply to this message...
System.Byte
System.Convert
System.IO.FileMode
System.IO.FileStream
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com