5 Replies - 569 Views - Last Post: 11 July 2011 - 10:02 PM Rate Topic: -----

#1 cfsharp  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 29-May 11

Trying to check a remote text file against a local one

Posted 09 July 2011 - 06:50 PM

Hey, i'm working in VB.net to create a program that checks the text in a remote text/html file against a local text file, and if the do not match, the program then does something. I keep getting an exception and i can't figure it out...

Here are the details of the exception:
http://pastebin.com/hJ3e8vDr

And here's the source i'm dealing with atm.

   Dim check As New StreamReader("localcheck.txt")
        Dim localcheck As String
        localcheck = check.ReadLine()
        'Dim check2 As New StreamReader("http://snip.com/")
        Dim remotecheck As String
        'remotecheck = check2.ReadLine()
        remotecheck = WebBrowser1.document.GetElementById("check").InnerText

        If remotecheck <> localcheck Then
            'Do stuff
            End If
        End If 


And here is the code for the HTML page that it's grabbing the element from:

<body id="check">
Stuff here
</body>



I'm not at all used to working in VB, and i'm not sure if i did that HTML right either, so that could be the problem.

This post has been edited by cfsharp: 09 July 2011 - 06:51 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Trying to check a remote text file against a local one

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Trying to check a remote text file against a local one

Posted 09 July 2011 - 10:56 PM

Use DocumentCompleted event and then check it.

and try to add a div inside body tag
<body>
     <div id="check">text...</div>
</body>


This post has been edited by noorahmad: 09 July 2011 - 10:59 PM

Was This Post Helpful? 1
  • +
  • -

#3 cfsharp  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 29-May 11

Re: Trying to check a remote text file against a local one

Posted 10 July 2011 - 09:27 AM

Hmm, that did fix the exception i was getting, but now the program is doing what it's supposed to do when the text is NOT the same, even though it is the same.

By the way, this line of code does mean != right?

If remotecheck <> localcheck Then


Was This Post Helpful? 0
  • +
  • -

#4 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Trying to check a remote text file against a local one

Posted 10 July 2011 - 10:14 PM

Yes, It means not equal
        Dim a As String = "abc"
        Dim b As String = "def"
        If a <> b Then
            MessageBox.Show("Not equal")
        Else
            MessageBox.Show("quals")
        End If

Was This Post Helpful? 1
  • +
  • -

#5 cfsharp  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 29-May 11

Re: Trying to check a remote text file against a local one

Posted 10 July 2011 - 11:33 PM

Oh alright then, i fixed the problem i was having. I typed a 3 into the html file instead of a what i was supposed to type.

I have one more thing i'm having trouble with. After the program does what it's supposed to do if the 2 strings are NOT equal. I want it to write the contents of the remotecheck string to the localcheck file. I tried using a StreamWriter, but it wasn't doing anything...
Was This Post Helpful? 0
  • +
  • -

#6 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Trying to check a remote text file against a local one

Posted 11 July 2011 - 10:02 PM

Try this:

Dim writer As New System.IO.StreamWriter("C:\file.txt")
writer.Write("Testing Line")
writer.Close()


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1