C#webbrowser上传文件

时间:2016-04-02 10:40:01

标签: c# file webbrowser-control uploading

您好我选择要在WebBrowser上传的文件有问题,我尝试这样做:

var elements = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement file in elements)
{
    if (file.GetAttribute("type") == "file")
    {
        file.Focus();
        file.InvokeMember("click");
        Thread.Sleep(2000);
        IntPtr fileDownloadDialogPointer = FindWindow(null, "select file dialog");
        SetForegroundWindow(fileDownloadDialogPointer);
        //SendKeys.SendWait("text");

        InputSimulator.SimulateTextEntry("text");
        }
    }

但这不起作用。怎么解决?我想在选择文件对话框中的字段中插入文本。

0 个答案:

没有答案
相关问题