Uri Class broken for authenticated URIs?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create an authenticated session to a remote FTP server using
the FtpWebClient class which takes a URI. Problem is, the URI doesn't seem to
accept standard ftp://username:password@server/ URIs and gives me the
following error when I try to get the propery serverUri.uri from below:

{"Invalid URI: A port was expected because of there is a colon (':') present
but the port could not be parsed."} System.FormatException
{System.UriFormatException}

Does anybody know what's going on?

UriBuilder serverUri = new UriBuilder();
serverUri.Scheme = Uri.UriSchemeFtp;
serverUri.Host = "servername.com";
serverUri.UserName = "username";
serverUri.Password = "password";

Thanks,

Leonard
 
Back
Top