参考链接 https://stackoverflow.com/questions/6773866/download-file-and-automatically-save-it-to-folder

    public class MyWebBrowser : WebBrowser
{
/// <summary>
/// The URLMON library contains this function, URLDownloadToFile, which is a way
/// to download files without user prompts. The ExecWB( _SAVEAS ) function always
/// prompts the user, even if _DONTPROMPTUSER parameter is specified, for "internet
/// security reasons". This function gets around those reasons.
/// </summary>
/// <param name="callerPointer">Pointer to caller object (AX).</param>
/// <param name="url">String of the URL.</param>
/// <param name="filePathWithName">String of the destination filename/path.</param>
/// <param name="reserved">[reserved].</param>
/// <param name="callBack">A callback function to monitor progress or abort.</param>
/// <returns>0 for okay.</returns>
/// source: http://www.pinvoke.net/default.aspx/urlmon/URLDownloadToFile%20.html
[DllImport("urlmon.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern Int32 URLDownloadToFile(
[MarshalAs(UnmanagedType.IUnknown)] object callerPointer,
[MarshalAs(UnmanagedType.LPWStr)] string url,
[MarshalAs(UnmanagedType.LPWStr)] string filePathWithName,
Int32 reserved,
IntPtr callBack); /// <summary>
/// Download a file from the webpage and save it to the destination without promting the user
/// </summary>
/// <param name="url">the url with the file</param>
/// <param name="destinationFullPathWithName">the absolut full path with the filename as destination</param>
/// <returns></returns>
public FileInfo DownloadFile(string url, string destinationFullPathWithName)
{
URLDownloadToFile(null, url, destinationFullPathWithName, , IntPtr.Zero);
return new FileInfo(destinationFullPathWithName);
}
}

然后使用这个MyWebBrowser控件代替.net自带的WebBrowser。

下载文件时使用

webBrowser1.DownloadFile(downloadUrl,"test.csv");

C# WebBrowser控件 下载文件不弹下载提示框的办法的更多相关文章

  1. WebBrowser控件禁用超链接转向、脚本错误提示、默认右键菜单和快捷键

    原文:WebBrowser控件禁用超链接转向.脚本错误提示.默认右键菜单和快捷键 WebBrowser控件禁用超链接转向.脚本错误提示.默认右键菜单和快捷键从 VS2005开始,VS自带的 WebBr ...

  2. 【iOS开发-56】案例BUG:button的enabled、控件的userInteractionEnabled以及两种提示框UIAlert和UIActionSheet

    接上述案例找BUG:[iOS开发-51]案例学习:动画新写法.删除子视图.视图顺序.延迟方法.button多功能使用方法及icon图标和启动页设置 (1)BUG:答案满了就不能再点击optionbut ...

  3. VB动态添加WebBrowser控件,并拦截弹出窗口(不用引用任何组件)

    新建空白窗体,然后粘帖下面代码: Option ExplicitPublic WithEvents br As VBControlExtender Private Sub br_ObjectEvent ...

  4. VC6.0 MFC中WebBrowser控件禁止新窗口弹出的解决办法

    http://blog.csdn.net/gnorth/article/details/7258293 分类: WebBrowser MFC 禁止新窗口2012-02-14 15:25 1787人阅读 ...

  5. WebBrowser控件使用技巧分享

    原文:WebBrowser控件使用技巧分享 在发布“淘宝登货员”时发现不少朋友对WebBrowser控件比较感兴趣,故在此分享一下使用心得. 首先分享一个WebBrowser的扩展类(此类所需的dll ...

  6. VC++ 使用WebBrowser控件中html文件以资源形式加载

    . . . . //加载资源文件中的HTML,IDR_HTML1就是HTML文件在资源文件中的ID wchar_t self_path[MAX_PATH] = { }; GetModuleFileNa ...

  7. WebBrowser控件应用:弹出新窗体和关闭窗口

    缘起:上次写了一个<WebBrowser控件的简单应用2>,提到了在NewWindow事件中打开新窗口的例子.有网友“队长 ”提出那个事件得到的参数是本页面的,而不是新页面的,经过测试,果 ...

  8. C# 禁止 Webbrowser 控件的弹出脚本错误对话框

    当IE浏览器遇到脚本错误时浏览器,左下 角会出现一个黄色图标,点击可以查看脚本错误的详细信息,并不会有弹出的错误信息框.当我们使用 WebBrowser控件时有错误信息框弹出,这样程序显的很不友好,而 ...

  9. 【WPF】监听WPF的WebBrowser控件弹出新窗口的事件

    原文:[WPF]监听WPF的WebBrowser控件弹出新窗口的事件 WPF中自带一个WebBrowser控件,当我们使用它打开一个网页,例如百度,然后点击它其中的链接时,如果这个链接是会弹出一个新窗 ...

随机推荐

  1. PMP备考-第二章-项目运行环境与项目经理

    组织系统的三大因素:组织治理框架,管理要素和组织结构 组织治理和项目治理 组织治理 :组织中的重要决策制定框架,谁有权在什么时候用什么发放做出并推行什么重要决策. 项目治理 :组织为项目建立的高级别的 ...

  2. Python从零开始——迭代器与生成器

    一:迭代器 二:生成器

  3. net core 2 读取appsettings.json

    问: .Net Core: Application startup exception: System.IO.FileNotFoundException: The configuration file ...

  4. Ubuntu 16.04/18.04 安装Shutter截图工具

    在安装Shutter软件之前,先安装依赖包,下载地址: 1.libgoocanvas-common_1.0.0-1_all.deb                 http://launchpadli ...

  5. JAVA的toString方法的一个小例子

    Object是一个抽象类,他有很有方法,其中的toString方法是我们常见的一个方法,我们可以看这段代码 package com.com.day1; public class ToStringTes ...

  6. ensorFlow的安装

    WIN7 64位系统 参考了  https://blog.csdn.net/appleyuchi/article/details/71036785 尝试了各种版本,,最后必须python安装3.60版 ...

  7. mac 修改 vim 配色

    1. 看看系统有哪些自带配色方案 ls /usr/share/vim/vim73/colors README.txt darkblue.vim delek.vim elflord.vim koehle ...

  8. 如何有效的清理yum缓存

    如果遇到下面问题,请执行下面命令   yum clean all   #清除缓存

  9. USACO wormhole

    洛谷 P1444 [USACO1.3]虫洞wormhole https://www.luogu.org/problemnew/show/P1444 JDOJ 2386: USACO 2013 Dec ...

  10. websocket广播式实例

    1.引入相关依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>sp ...