【发布时间】:2011-06-11 21:21:45
【问题描述】:
if (webBrowser1.DocumentText.IndexOf("Page: 1") != -1)
在上面一行我得到了这个异常
System.IO.FileNotFoundException 是 unhandled Message="系统无法 找到指定的文件。 (例外 来自 HRESULT:0x80070002)"
来源="System.Windows.Forms"
堆栈跟踪: 在 System.Windows.Forms.UnsafeNativeMethods.IPersistStreamInit.Save(IStream pstm,布尔 fClearDirty) 在 System.Windows.Forms.WebBrowser.get_DocumentStream() 在 System.Windows.Forms.WebBrowser.get_DocumentText() 在 WindowsFormsApplication1.Form1.GenerateETGWorklists() 在 C:\Documents 和 设置\阿戈登\我的文档\视觉 工作室 2008\Projects\GenerateWorklists\GenerateWorklists\Form1.cs:line 603 在 WindowsFormsApplication1.Form1.btnProcess_Click(对象 发件人,EventArgs e) 在 C:\Documents 和设置\阿戈登\我的 文档\Visual Studio 2008\Projects\GenerateWorklists\GenerateWorklists\Form1.cs:line 55 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs 事件) 在 System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons 按钮,Int32 点击) 在 System.Windows.Forms.Control.WndProc(消息& 米) 在 System.Windows.Forms.ButtonBase.WndProc(消息& 米) 在 System.Windows.Forms.Button.WndProc(消息& 米) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& 米) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& 米) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr 参数) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& 味精) 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID,Int32 原因,Int32 pvLoopData) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 原因,ApplicationContext 上下文) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 原因,ApplicationContext 上下文) 在 System.Windows.Forms.Application.Run(窗体 主窗体) 在 WindowsFormsApplication1.Program.Main() 在 C:\Documents 和 设置\阿戈登\我的文档\视觉 工作室 2008\Projects\GenerateWorklists\GenerateWorklists\Program.cs:line 18 在 System.AppDomain._nExecuteAssembly(程序集 程序集,字符串 [] 参数) 在 System.AppDomain.ExecuteAssembly(字符串 汇编文件,证据 装配安全,字符串 [] 参数) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(对象 状态) 在 System.Threading.ExecutionContext.Run(ExecutionContext 执行上下文,上下文回调 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart() 内部异常:
这是什么意思?我昨天没有收到这个错误,今天收到了。网页打开没问题,文字Page: 1肯定在那里。
这是一个类似的问题,也没有解决方案 http://bytes.com/topic/c-sharp/answers/657812-webbrowser-documenttext-getting-problem
【问题讨论】:
-
WebBrowser显示的是什么? -
您需要检查该文件是否仍在您的代码调用它的位置,没有其他进程正在使用该文件,并且权限仍然允许写入和读取文件
-
@daniel 还没有文件。它从网页中获取
-
@JOE,你确定你已经安装了 IE 及其所有核心文件和 dll 吗?
-
@dead 昨天工作正常