I am currently working on a project that needs to be able to set the value of an input element of type "file" in an HTML document using mshtml.HTMLInputFileElement. I am having a great deal of difficulty doing this.
First I tried this:
IHTMLInputFileElement element = (IHTMLInputFileElement)args[0];
string filename
element.value = newFileName;
But the value was not set. I then read on another forum that the value property could not be set directly, but could be set by giving the focus to that input element and then using SendKeys to send the value to the file element like so:
HTMLInputElement writableFileElement = (HTMLInputElement)element;
writableFileElement.focus();
SendKeys.SendWait(newFileName);
this also failed and threw a COM exception saying that the field was not writable.
Is there any way to set the value field of an HTMLInputFileElement?