473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Howto open a file dialogbox (Save As) when using WriteFile

Hi,

This is the code I am using:

string filepath = "Themes/img/logo.rar";

string filename = System.IO.Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/zip";

Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.Flush();
Response.WriteFile(filepath);

Instead of the choice of saving the file its content is output in the
browser.

Thanks in advance,
Anders
Nov 18 '05 #1
3 1512
Hi,

Did you try Response.BinaryWrite instead of Response.WriteFile()?

"Anders" <mo****@gmail.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
Hi,

This is the code I am using:

string filepath = "Themes/img/logo.rar";

string filename = System.IO.Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/zip";

Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.Flush();
Response.WriteFile(filepath);

Instead of the choice of saving the file its content is output in the
browser.

Thanks in advance,
Anders

Nov 18 '05 #2
If I use BinaryWrite ill have to change all the code, specify the filepath
from the root and give ASPNET access to the path which I dont know how to do
in WinXP.

Best,
Anders
"Shiva" <sh******@online.excite.com> wrote in message
news:eZ**************@TK2MSFTNGP09.phx.gbl...
Hi,

Did you try Response.BinaryWrite instead of Response.WriteFile()?

"Anders" <mo****@gmail.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
Hi,

This is the code I am using:

string filepath = "Themes/img/logo.rar";

string filename = System.IO.Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/zip";

Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.Flush();
Response.WriteFile(filepath);

Instead of the choice of saving the file its content is output in the
browser.

Thanks in advance,
Anders

Nov 18 '05 #3
I added Reponse.Buffer = true just before the Response.Clear(); and now it
works!

Cheers,
A
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: prettysmurfed | last post by:
Hi all I have a bit of a problem, the subject of this post is almost selfexplaing. But here goes: Heres an example of the code I want to implement, its all nice and simple, but the flaw is I...
4
by: John | last post by:
Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download"...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
4
by: David | last post by:
Hi all, I am trying to write a class file, but am not quite sure what I am doing. What I want to do is from within an ASP page is to call a class. The class must then create a text file...
7
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. I would like a command button in VB.Net 2002 to open a text file, then to allow text from a textbox on the current form...
0
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
6
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
0
by: de4ever | last post by:
I have used open/save dialog box inside update panel in asp.net.but it is not working because of the code line Response.WriteFile(path);.Can i use any thing else for opening a file through open/save...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.