Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi guys
im using c# web browser and i want to save some of pages when a key is pressed but when i use SaveFileDialgue a window pop ups and asks for destination!is there any way to save it directly to a specific destination without prompting me?

here it is my code:

private void btnSubmit_Click(object sender, EventArgs e)
       {
           browser.Navigate("https://www.google.com/");
           SaveFileDialog sfd = new SaveFileDialog();
           sfd.Filter = " TEXT File |*.txt";
           if (sfd.ShowDialog() == DialogResult.OK)
           {
               browser.SaveDocument(sfd.FileName);
           }

       }

Tanx
Posted
Comments
[no name] 19-Aug-12 11:41am    
Yes.... don't show the dialog.
khangaldi 19-Aug-12 12:03pm    
but how can i set a path then?
[no name] 19-Aug-12 12:11pm    
If you are not using the dialog then you have to use code to do it. How else did you think?
Richard MacCutchan 19-Aug-12 11:53am    
You could skip showing the dialog, but how do you then know that you have a valid and accessible destination to save the file into?

Remove your

SQL
if (sfd.ShowDialog() == DialogResult.OK)
 
Share this answer
 
Comments
khangaldi 19-Aug-12 12:01pm    
but how can i set a path then?
fjdiewornncalwe 24-Aug-12 16:36pm    
If you don't want a prompt, then you have to specify the path in your code directly.
This is the code for saving a file directly without using dialog box.Now try it for yours..
// create reader & open file in C drive or your location
TextWriter tr = new StreamWriter(@"C:\" + "example.txt");

// read a line of text
tr.WriteLine(richTextBox1.Text);

// close the stream
tr.Close();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900