Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free
#

 

Problem: In a Windows Forms application, the HTML code of a Web page is read and placed into an HTML document.

But then the error appears: Illegal characters in path

//< get HTMLdocument >

string sHTML = TextReader.ReadToEnd();

_doc = new html.HtmlDocument();

_doc.Load(sHTML);

//</ get HTMLdocument >

 

 

Error message:

System.ArgumentException occurred

  HResult=0x80070057

  Message=Illegal characters in path.

 

Solution:

HTML Assign with .LoadHTML (..) instead of .Load (..)

_doc.LoadHtml(sHTML);

 

 

Incorrect C # code

          

html.HtmlDocument _doc ;

 

string sURL = tbxURL.Text;

 

WebRequest objRequest = WebRequest.Create(sURL);

HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();

 

//< Webseite auslesen >

Stream objDataStream = objResponse.GetResponseStream();

//</ Webseite auslesen >

 

//< Text auslesen >

StreamReader TextReader = new StreamReader(objDataStream);

//</ Text auslesen >

 

//< get HTMLdocument >

string sHTML = TextReader.ReadToEnd();

_doc = new html.HtmlDocument();

_doc.Load(sHTML);

//</ get HTMLdocument >

 

 

 

 

 

 

#html webbrowser web browser, htmldocumen

 

 

error message

System.ArgumentException occurred

  HResult=0x80070057

  Message=Illegal characters in path.

  Source=mscorlib

  StackTrace:

   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)

   at System.IO.Path.GetFileName(String path)

   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)

   at System.IO.StreamReader..ctor(String path, Encoding encoding)

   at HtmlAgilityPack.HtmlDocument.Load(String path) in C:\Users\stgrell\Source\Workspaces\htmlagilitypack\Trunk\HtmlAgilityPack\HtmlDocument.PathMethods.cs:line 75

   at webrobot_ebayKleinanzeigen.Form1.fl_Test() in C:\_Daten\Desktop\WinForms\WebRobot\Fahrrad\webrobot_ebayKleinanzeigen\webrobot_ebayKleinanzeigen\Form1.cs:line 54

   at webrobot_ebayKleinanzeigen.Form1.btnRead_Click(Object sender, EventArgs e) in C:\_Daten\Desktop\WinForms\WebRobot\Fahrrad\webrobot_ebayKleinanzeigen\webrobot_ebayKleinanzeigen\Form1.cs:line 28

   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(IntPtr 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 webrobot_ebayKleinanzeigen.Program.Main() in C:\_Daten\Desktop\WinForms\WebRobot\Fahrrad\webrobot_ebayKleinanzeigen\webrobot_ebayKleinanzeigen\Program.cs:line 19

 

Mobile
»
Winforms Webbrowser: HTMLDocument.load Illegal characters in path
»
Winforms Webbrowser: HTMLDocument.load Illegal characters in path

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de