Hello,
I have a WinForms C# application. There is a WebBrowser control on the form named "browser".
Also I have following code:
HtmlDocument doc = browser.Document;
HtmlElement mForm = doc.GetElementById("TheFormId");
doc.GetElementById("Name").SetAttribute( "value", "Some Name" );
HtmlElement elFile = doc.GetElementById( "TheFile" );
elFile.Focus();
SendKeys.Send( "C:\\1.txt" );
mForm.InvokeMember( "submit" );
The problem is that it does not submit a file. If I manually type in file name in the corresponding input box - it works.
Environment: Win XP SP2, IE6, VS 2008
Edit: This fixed the problem:
SendKeys.Send( "C:\\1.txt" + "{ENTER}" );