codedocu.de

 

 

 

Problem: bei einer Windows Forms Anwendung wird der HTML Code einer Webseite ausgelesen und in ein HTML Dokument zugewiesen.

Dann erscheint aber der Fehler: Illegal characters in path

//< get HTMLdocument >

string sHTML = TextReader.ReadToEnd();

_doc = new html.HtmlDocument();

_doc.Load(sHTML);

//</ get HTMLdocument >

 

 

Fehlermeldung:

System.ArgumentException occurred

  HResult=0x80070057

  Message=Illegal characters in path.

 

Lösung:

HTML Zuweisen mit .LoadHTML(..) anstatt .Load(..)

_doc.LoadHtml(sHTML);

 

 

Fehlerhafter 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 >

 

 

 

 

Winforms Webbrowser: HTMLDocument.load Illegal characters in path

 

 

 

Fehlermeldung

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

  

winforms, windows forms webbrowser web browser control html read


Software Entwicklung Stuttgart Nürtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel