Why does this var uri = new Uri("ftp://1111:2222:3333::43/testing/1kb.zip");
Throw this exception?
System.UriFormatException: Invalid URI: Invalid port specified. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
From RFC 2732:
To use a literal IPv6 address in a URL, the literal address should be enclosed in "[" and "]" characters.
For example, this works fine:
var uri = new Uri("ftp://[1111:2222:3333::43]/testing/1kb.zip");
If you want to specify the port, it needs to be outside the square brackets:
var uri = new Uri("ftp://[1111:2222:3333::43]:100/testing/1kb.zip");
See more on this question at Stackoverflow