Response.ClearContent();
// Response.ClearHeaders();
// Response.ContentType = "application/pdf";
// Response.AddHeader("Content-Disposition", "attachment; filename="+ reportName);
// Response.WriteFile(reportPath + reportName);
// Response.Flush();
// Response.Close();
in saving a file for some reason I do not want to use it anymore is there anyway to ask the user where he or she wants to save her file??
Save a file
Page 1 of 19 Replies - 16793 Views - Last Post: 13 January 2009 - 02:03 PM
#1
Save a file
Posted 06 January 2009 - 02:59 AM
hi I use
Replies To: Save a file
#2
Re: Save a file
Posted 06 January 2009 - 03:06 AM
Yes!
With a SaveFileDialog
Just add a SaveFileDialog from the toolbox and insert the following code.
example:
edit: i made it a bit cleaner and added it into a buttonclick event
hope this helps
regards
B.Ihde
With a SaveFileDialog
Just add a SaveFileDialog from the toolbox and insert the following code.
example:
private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = saveFileDialog1.OpenFile()) != null)
{
// Code to write the stream goes here.
myStream.Close();
}
}
}
edit: i made it a bit cleaner and added it into a buttonclick event
hope this helps
regards
B.Ihde
This post has been edited by b.ihde: 06 January 2009 - 03:40 AM
#3
Re: Save a file
Posted 06 January 2009 - 05:39 PM
im only using vs 2003 is it applicable there?
#4
Re: Save a file
Posted 06 January 2009 - 05:45 PM
oasisjoel, on 6 Jan, 2009 - 04:39 PM, said:
im only using vs 2003 is it applicable there?
Did you give it a try? Come on guys put some effort in!
mebbe not a good sign...
Quote
Two ways to solve your problem
1.Think of a solution yourself Go to www.dreamincode.net
2. Post your problem in www.dreamincode.net
1.
2. Post your problem in www.dreamincode.net
This post has been edited by badjava: 06 January 2009 - 05:47 PM
#5
Re: Save a file
Posted 06 January 2009 - 05:54 PM
I already tried before I ask if it will work, cause it doesnt work for me some of variable are not detected maybe some need to be declared
btw it is said in the error that im missing an assembly reference I dont if the error only rises in 2003 because it not that complete compare to 2005 and 2008
btw it is said in the error that im missing an assembly reference I dont if the error only rises in 2003 because it not that complete compare to 2005 and 2008
#6
Re: Save a file
Posted 07 January 2009 - 12:42 AM
Did you added the System.IO namespace?
regards
B.Ihde
EDIT: i really have to agree with BadJava about your sign..
You always should to try to solve your problem on your own at FIRST!!!
using System.IO;
regards
B.Ihde
EDIT: i really have to agree with BadJava about your sign..
You always should to try to solve your problem on your own at FIRST!!!
This post has been edited by b.ihde: 07 January 2009 - 12:44 AM
#7
Re: Save a file
Posted 13 January 2009 - 11:44 AM
I'm getting a error with ihde's code:
Error 3 The type or namespace name 'SaveFileDialog' could not be found (are you missing a using directive or an assembly reference?)
This is a C# web application.
I don't see a SaveFileDialog item in the toolbox but when I right click it and select 'choose items' it is selected so maybe it's just not available for web applications??
Anyway around this?
Error 3 The type or namespace name 'SaveFileDialog' could not be found (are you missing a using directive or an assembly reference?)
This is a C# web application.
I don't see a SaveFileDialog item in the toolbox but when I right click it and select 'choose items' it is selected so maybe it's just not available for web applications??
Anyway around this?
#8
Re: Save a file
Posted 13 January 2009 - 12:26 PM
#9
Re: Save a file
Posted 13 January 2009 - 12:56 PM
For anyone in the future wondering this is how you have to do it from a web app:
http://forums.asp.ne...spx?PageIndex=1
I'm not the OP.
http://forums.asp.ne...spx?PageIndex=1
b.ihde, on 13 Jan, 2009 - 11:26 AM, said:
I'm not the OP.
This post has been edited by pidass: 13 January 2009 - 12:56 PM
#10
Re: Save a file
Posted 13 January 2009 - 02:03 PM
ya i figured out that too ... so i m sorry 
Also welcome to DIC!
Also welcome to DIC!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|