Hey,
I've got a basic app that reads an ip from a webpage (whatismyip.org) using streamreader and I use the following code to make sure I read just the first 15 characters from the stream.
This all works perfectly.
The problem is I need to verify that an ip has been retrieved and not some random crap, which would happen if the webpage changed for example.
I've tried using the IPAddress.TryParse() command to verify the address, but it does work and returns false because an input string is required and not a char.
So I've tried;
All of which, when validated with IPAddress.TryParse() return false.
Yet if I try this;
The code returns true as it should.
So it's definitely at problem with the char to string conversion.... maybe encoding?
Thanks
Danny
I've got a basic app that reads an ip from a webpage (whatismyip.org) using streamreader and I use the following code to make sure I read just the first 15 characters from the stream.
VB.NET:
Dim ip(15) As Char
Do While sr.Peek >= 0
sr.Read(ip, 0, ip.Length)
Loop
This all works perfectly.
The problem is I need to verify that an ip has been retrieved and not some random crap, which would happen if the webpage changed for example.
I've tried using the IPAddress.TryParse() command to verify the address, but it does work and returns false because an input string is required and not a char.
So I've tried;
VB.NET:
Dim isValidIP As String = CStr(ip)
VB.NET:
Dim isValidIP As New String(ip)
VB.NET:
Dim isValidIP As String = ip.string
All of which, when validated with IPAddress.TryParse() return false.
Yet if I try this;
VB.NET:
Dim ip As String = "87.34.67.112"
Dim isValidIP as Boolean
isValidIP = IPAddress.TryParse(ip, Nothing)
The code returns true as it should.
So it's definitely at problem with the char to string conversion.... maybe encoding?
Thanks
Danny