Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

if (webBrowser1.DocumentText.IndexOf("Page: 1") != -1)

on the above line i am getting this exception

System.IO.FileNotFoundException was unhandled Message="The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"
Source="System.Windows.Forms"
StackTrace: at System.Windows.Forms.UnsafeNativeMethods.IPersistStreamInit.Save(IStream pstm, Boolean fClearDirty) at System.Windows.Forms.WebBrowser.get_DocumentStream() at System.Windows.Forms.WebBrowser.get_DocumentText() at WindowsFormsApplication1.Form1.GenerateETGWorklists() in C:Documents and SettingsagordonMy DocumentsVisual Studio 2008ProjectsGenerateWorklistsGenerateWorklistsForm1.cs:line 603 at WindowsFormsApplication1.Form1.btnProcess_Click(Object sender, EventArgs e) in C:Documents and SettingsagordonMy DocumentsVisual Studio 2008ProjectsGenerateWorklistsGenerateWorklistsForm1.cs:line 55 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsFormsApplication1.Program.Main() in C:Documents and SettingsagordonMy DocumentsVisual Studio 2008ProjectsGenerateWorklistsGenerateWorklistsProgram.cs:line 18 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

what is the meaning of this? i did not get this error yesterday and getting it today. the webpage opens no problem and the text Page: 1 is definitely there.

here is a similar issue also without solution http://bytes.com/topic/c-sharp/answers/657812-webbrowser-documenttext-getting-problem

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
294 views
Welcome To Ask or Share your Answers For Others

1 Answer

this is a known bug and microsoft doesn't do anything about it for vs2008 at least. here's a fix:

String lastsource = ((mshtml.HTMLDocumentClass)(((webBrowser1.Document.DomDocument)))).documentElement.innerHTML;
            webBrowser1.Document.OpenNew(true);
            webBrowser1.Document.Write(lastsource);  

now we can access DocumentText with no problems

dont forget to import mshtml as a reference


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...