当前位置: 首页 > 编程语言 > C#

c#filenotfoundexceptiononwebbrowser-在

时间:2023-04-10 23:09:52 C#

webbrowser上共享c#filenotfoundexception?if(webBrowser1.DocumentText.IndexOf("Page:1")!=-1)在上面的行中我得到这个异常System.IO.FileNotFoundExceptionUnhandledMessage="Thesystemcannotfindthefilespecified.(HRESULTexception:0x80070002)"Source="System.Windows.Forms"StackTrace:System.Windows在System.Windows.Forms.WebBrowser.get_DocumentStream()在System.Windows.Forms.WebBrowser.get_DocumentText()在Windows.msApplication1.Form1.Forms.UnsafeNativeMethods.IPersistStreamInit.Save(IStreampstm,BooleanfClearDirty)。GenerateETGWorklists()inC:DocumentsandSettingsagordonMyDocumentsVisualStudio2008ProjectsGenerateWorklistsGenerateWorklistsForm1.cs:Line603ofWindowsFormsApplication1.Form1.btnProcess_Click(Objectsender,EventArgse)inC:DocumentsandSettingsagordonMyDocumentsVisualStudio2008项目GenerateWorklistsGenerateWorklistsForm1.cs:System.Windows.Forms.Control.OnClick(EventArgse)atSystem.Windows.Forms.Button.OnClickonline55(EventArgs)e)atSystem.Windows.Forms。在System.Windows.Forms.Control.WmMouseUp(Message&m,MouseButtonsbutton,Int32click)在System.Windows.Forms.Button.OnMouseUp(MouseEventArgsmevent)在Connd.WndProc(Message&m)。System.Windows.Forms.ButtonBase.WndProc(Message&m)在System.W上消息&m)。在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager的System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&msg)的NativeWindow.DebuggableCallback(IntPtrhWnd,Int32msg,IntPtrwparam,IntPtrlparam)System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)的System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32原因,ApplicationContext上下文)中的.FPushMessageLoop(Int32dwComponentID,Int32原因,Int32pvLoopData)在System.Windows.Forms.Application.Run(FormmainForm)中的WindowsFormsApplication1.Program.Main()在C:DocumentsandSettingsagordonMyDocumentsVisualStudio2008ProjectsGenerateWorklistsGenerateWorklistsProgram.cs:line1System.Threading上的Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()处的System.AppDomain.ExecuteAssembly(StringassemblyFile,EvidenceassemblySecurity,String[]args)上的System.AppDomain._nExecuteAssembly(Assemblyassembly,String[]args)位于8System.Threading.ThreadHelper.ThreadStart()ThreadStart_Context(对象状态):InnerException:这是什么意思?昨天没报错,今天报错网页打开没问题,文本Page:1肯定存在。这是一个没有解决方案的类似问题http://bytes.com/topic/c-sharp/answers/657812-webbrowser-documenttext-getting-problem这是一个已知的错误,微软至少没有为vs2008做任何事情。这是一个修复:Stringlastsource=((mshtml.HTMLDocumentClass)(((webBrowser1.Document.DomDocument)))).documentElement.innerHTML;webBrowser1.Document.OpenNew(true);webBrowser1.Document.Write(lastsource);现在我们可以毫无问题地访问DocumentText不要忘记导入mshtml以供参考尝试webBrowser1.Document.Body.InnerText。我还发现奇怪的是,当我从网络加载页面时,网络浏览器控件抛出了与文件访问相关的异常。在研究这个问题时,我注意到了一些奇怪的事情:最近在清除临时Internet文件时,这个错误不太常见。我修改了我的应用程序以在应用程序启动时自动清除临时Internet文件,这足以解决90%的错误。我用于清理临时Internet文件的代码如下...我不认为这适用于所有操作系统-可能有更好的方法-但这符合我的需要,因为它适用于Server2008。(我的代码在vb中.net,不过c#版本应该不会太难理解。)以上是C#学习教程:c#filenotfoundexceptiononwebbrowser?分享的所有内容,如果对你有用,需要了解更多C#学习教程,希望你多多关注——'开始清理互联网临时文件DimclearFilesProcessAsProcess=System.Diagnostics.Process。Start("rundll32.exe","InetCpl.cpl,ClearMyTracksByProcess255")'等待网络临时文件被删除WhileNot(clearFilesProcess.HasExited)System.Threading.Thread.Sleep(200)EndWhile本文已收来自网络,不代表立场,如涉及侵权,请点击右边联系管理员删除。如需转载请注明出处: