[英]save page in c# webbrowser without savefiledialogue
I'm 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! 我正在使用
C#
Web浏览器,并且想在按下某个键时保存一些页面,但是当我使用SaveFileDialgue时,会弹出一个窗口并询问目的地! 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);
}
}
remove the following lines 删除以下几行
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = " TEXT File |*.txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
browser.SaveDocument(sfd.FileName);
}
add 加
browser.SaveDocument("c:\\outputfile.txt");
You can read all the page using 您可以使用阅读所有页面
private void BtnSaveHtml_Click(object sender, EventArgs e)
{
// webBrowser1.ShowSaveAsDialog();
string html;
html = webBrowser1.DocumentText.ToString();
}
and with the help of stream writer you save all the data where you want to save. 并在流编写器的帮助下将所有数据保存到要保存的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.