When using WebClient I can specify a URL as the address when connecting to an FTP server, but when specifying an IP address it throws a FormatException inside mscorlib. Basically, to demonstrate:
using (WebClient client = new WebClient())
{
client.UploadFile("ftp://localhost/test.dat", "STOR", "test.dat"); // No exception
client.UploadFile("ftp://127.0.0.1/test.dat", "STOR", "test.dat"); // FormatException
}
The exception detail says "Input string was not in a correct format" and claims to be coming from System.Number.StringToNumber
I have tried it with and without the ":21" port number, but it makes no difference.
How can I use an IP Address with the WebClient class to upload a file to an FTP server?