上载文件不起作用-剪裁初始字符 [英] Uploading Files Not Working - trim the initial characters

查看:79
本文介绍了上载文件不起作用-剪裁初始字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WebBrowser控件上载文件.它会修剪起始字符,有时是一个,有时是三个,然后选择窗口给出错误Invalid file name!.似乎无法做到,需要一些帮助.

I am trying to upload a file using the WebBrowser control. It trims the starting character sometimes one and sometimes three then choose window gives error Invalid file name!. Can't seem to do it and need some help.

这是HTML:

    <input name="UploadedFile" id="UploadedFile" type="file" />
    <input name="up" id="up" type="button" value="Upload" />

这是vb代码:

Dim el = elc.GetElementsByName("UploadedFile")
el.Item("UploadedFile").Focus()
'    SendKeys.Send("Capture.png" & "{ENTER}")
SendKeys.Send("C:\Capture.png" + "{ENTER}")
el.Item("UploadedFile").InvokeMember("Click")

出现文件上传按钮,然后按Enter键,但无法在文件名区域中输入完整的文件名.

that the file upload button comes up and hit enter, but can't input full filename into the file name area.

如果我使用此SendKeys.Send("C:\Capture.png" + "{ENTER}").它给出了这个错误: 选择窗口错误屏幕截图

If I use thisSendKeys.Send("C:\Capture.png" + "{ENTER}"). It gives this error: Choose window error screenshot

如果我使用此SendKeys.Send("Capture.png" + "{ENTER}").它给出了这个错误: 选择窗口错误屏幕截图

If I use this SendKeys.Send("Capture.png" + "{ENTER}"). It gives this error: Choose window error screenshot

如果我放置额外的字符,那么它可以正常工作,但它并不总是修剪一个字符,因此我不能放置额外的字符来解决此错误.

And if I put extra character then it works fine but it doesn't always trim one character so I can't put an extra character to solve this error.

推荐答案

您是正确的@soohoonigan,发送密钥的速度太快了,但这并不是答案.我是那样做的.

You are right @soohoonigan the sendkeys comes up too fast but that is not an answer for that. I did this like that.

这是我的代码:

Dim el = elc.GetElementsByName("UploadedFile")
SetFile()
el.Item("UploadedFile").InvokeMember("Click")

Public Async Sub SetFile()

       Await Task.Delay(1000)
       SendKeys.Send("c:\Capture.png" & "{ENTER}")

End Sub

一切正常.

这篇关于上载文件不起作用-剪裁初始字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆