Hi,
I’m using to download a file from server the following code:
string fn=”abc.pdf”;
MemoryStream ms = new MemoryStream();
using (FileStream file = new FileStream(nf, FileMode.Open, FileAccess.Read)) file.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
Application.DownloadAndOpen(“_blank”, ms, fn);
I’m using something similar for some memory streams created directly in memory. The general idea is:
Hi Levie,
The code (similar with my own) is working and no error occur. The (strange) behavior is like following:
I attach the save dialog in both situations.
Hi Adrian,
What do you mean when you say it doesn’t work? What error does it throw?
Try this:
Application.DownloadAndOpen("_blank", Application.MapPath("abc.pdf"));
Your code was working for me like this:
string fn = Application.MapPath("abc.pdf"); MemoryStream ms = new MemoryStream(); using (FileStream file = new FileStream(fn, FileMode.Open, FileAccess.Read)) file.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); Application.DownloadAndOpen("_blank", ms, fn);
Let me know how to help!
Best,
Levie
Please login first to submit.