0
当使用WebClient时,我可以在连接到FTP服务器时指定URL作为地址,但是当指定IP地址时,它会在mscorlib中引发FormatException。基本上,证明:使用WebClient上传到FTP的FormatException
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
}
异常详细信息说“输入字符串的不正确的格式”,并声称是从System.Number.StringToNumber
未来我已经有和没有尝试过的“ :21“端口号,但没有区别。
如何使用带有WebClient类的IP地址将文件上传到FTP服务器?
我无法重现该问题。它适用于我'127.0.0.1'。向我们展示一个完整的异常调用堆栈(包括内部异常调用堆栈)和['WebClient'日志文件](https://stackoverflow.com/q/9664650/850848)。 –