Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3754580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:34:01+00:00 2026-05-19T09:34:01+00:00

if (webBrowser1.DocumentText.IndexOf(Page: 1) != -1) on the above line i am getting this exception

  • 0
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
Settings\agordon\My Documents\Visual
Studio
2008\Projects\GenerateWorklists\GenerateWorklists\Form1.cs:line
603
at WindowsFormsApplication1.Form1.btnProcess_Click(Object
sender, EventArgs e) in C:\Documents
and Settings\agordon\My
Documents\Visual Studio
2008\Projects\GenerateWorklists\GenerateWorklists\Form1.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
Settings\agordon\My Documents\Visual
Studio
2008\Projects\GenerateWorklists\GenerateWorklists\Program.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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:34:01+00:00Added an answer on May 19, 2026 at 9:34 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why I'm getting this error? System.InvalidCastException was unhandled by user code Message=Specified cast is
Trying to get this line to work mshtml.IHTMLDocument2 doc2 = webBrowser1.Document as mshtml.IHTMLDocument2; but
if (webBrowser1.Url.AbsoluteUri == www.google.com) { label9.Text = webBrowser1.Url.AbsoluteUri; } This is my current code.
I have an event when fired does this: htmlView.DocumentText = contentArea.Text; The problem is
I'm using this code which is meant to check the text in webBrowser1, although
This is my code: webBrowser1.ObjectForScripting = this; string str = <html><head><script type=\text/javascript\> + var
When I do something like this webBrowser1 = new WebBrowser(); webBrowser1.Url = new Uri(http://google.com);
I use webBrowser.DocumentText to get the html code of a page. using Regex, i
IndexOutOfRangeException was unhandled string ebtocosname; ebtocosname = webBrowser2.Document.GetElementById(Fullname).GetAttribute(value); var NAMES = ebtocosname.Split(); webBrowser1.Document.GetElementById(FirstName).SetAttribute(value, NAMES[0]);
I tried with no success: webBrowser1.Document.ExecCommand(alert('Hello World!'), true, null); also tried: private void webBrowser1_DocumentCompleted(object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.