I am trying to make a connection via HttpWebRequest. I am reading url links from a text file. However, I am getting 'System.UriFormatException' error.
I have tried to add http:// in front of the url links in my text file. But the result is the same.
What can be the solution?
If the error only occurs when reading the values from a file, but not when assigned directly to a string
variable, then I'm guessing that there are extra characters being read (quotes, escaped characters, carriage-return/line feeds, etc).
Try reading the first value into a string
, and then comparing that to what you expect in the explicit string
value. Any differences should be obvious after that.
Without seeing code it's impossible to tell what you're trying to do. But you can start by looking at the Message property of the UriFormatException class. Message
is a string that explains the reason for the exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With