在 Webbrowser 控件 VB.net 2010 中以编程方式选择输入:文件
我有一个网站,我通过 VB.Net 2010 通过 WebBrowser 控件填写表单数据。
我能够设置输入值:文本、输入:密码、复选框、选择并能够提交表单。
但我无法以编程方式选择输入:文件。我也能打开 “选择文件”对话框。
如何从 VB.Net 代码发送文件名以选择并按“确定”按钮?
I have a website where I am filling form data through VB.Net 2010 through WebBrowser control.
I am able to set value for input:text, input:password, checkbox, select and able to submit form.
But I am not able to select input:file programmatically. I am also able to open
"Choose a File" Dialog.
How can I send file name to select and press OK button from VB.Net Code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定这是一个浏览器安全功能,可以防止恶意网站自动从用户的网站上传随机文件给自己。考虑一下,如果任何网站可以在用户不采取任何明确操作的情况下从用户计算机上提取任意文件,那将是多么危险。
您最好的选择可能是放弃 Web 浏览器控件,因为它将限制您使用其安全模型。相反,请考虑直接获取网页并在应用程序中发布响应。
以下 .NET 命名空间应该能派上用场:
System.Net.HTTPWebRequest
System.Net.TTPWebResponse
I am pretty sure this is a browser security feature to prevent malicious web-sites from auto-uploading random files from the user's website to themselves. Consider how dangerous it would be if any website could pull arbitrary files off the user's computer without any explicit action from the user.
Your best bet is probably going to be dumping the Web Browser control since it will limit you to its security model. Instead consider directly getting the web page and posting a response within your application.
The following .NET namespaces should come in handy for that:
System.Net.HTTPWebRequest
System.Net.TTPWebResponse