
04-11-2012, 01:10 AM
|
|
Newcomer
|
|
Join Date: Apr 2012
Posts: 1
|
|
Save all Links in Webpage
|
Hello Friends,
I am a complete newbie in this programing language. The thing that I am trying to achieve is -
1) Create a simple Web Browser [DONE]
2) Clear Cookies by Mouse Click on the Button [DONE]
3) Save the links present in the webpage that the user is viewing through my browser [PROBLEM]
Here's the code that I have done -
Code:
Imports System.IO
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate(TextBox1.Text)
Using MyWriter As New StreamWriter("C:\Documents and Settings\Administrator\Desktop\test.txt")
'Declare your StreamWriter and put the path to the file that you want to write as a Parameter of the StreamWriter. If the File does not exist, then it will be created. If the File Exists it will be overwritten. (You can add the Append Boolean to the Parameters of the StreamWriter if you don't want the File overwritten. StreamWriter(PathToFile, AppendBoolean))
Dim MyString As String = WebBrowser1.Document.Body.InnerText ' Declare your String and set the Value of the String to be the InnerText of the document in the WebBrowser Control
MyWriter.Write(MyString) ' Write the String to the File
MyWriter.Flush() ' Clear the buffers for the current writer and causes any buffered data to be written to the underlying stream
MyWriter.Close() ' Close the StreamWriter
End Using
End Sub
But when I try to debug this I get this error -
A first chance exception of type 'System.NullReferenceException' occurred in MyWebBrowser.exe
and this line gets highlighted in yellow - MyString As String = WebBrowser1.Document.Body.InnerText
Please help!!
|
|