FtpClient.OpenRead(uri) and Uri with whitespaces

May 6, 2015 at 2:32 PM
Edited May 8, 2015 at 1:37 PM
Edit: Problem solved

Hi,

following code:
string dummy = "ftp://192.168.8.99/Configuration/filename with whitespace.xml";
uriDummy = new Uri(dummy);
istream = FtpClient.OpenRead(uriDummy);
causes FtpCommandException "File Not Found".
The file exists on the server. No Problem with file names without whitespace.
I tried to convert the uri with Uri.EscapeUriString, so the whitespace will be replaced with %20
but that didn't help. Same exception: "File Not Found".

I use the .NET 2.0 version!

What is the problem here? How can I solve it?
Here is the log from the trace listener
220 Service Ready 
USER ftp
331 User name ok, need password
PASS <omitted>
230 User logged in
FEAT
500 Unrecognized command
Text encoding: System.Text.ASCIIEncoding
TYPE I
200 Switching to binary mode
SIZE /Configuration/Consumption%20Counter.ini
550 File not found
EPSV
500 Unrecognized command
PASV
227 Entering passive mode (192,168,8,99,5,128)
InterNetwork: 192.168.8.99
RETR /Configuration/Consumption%20Counter.ini
550 File not found
File not found
I tried another overload of the OpenRead Method (OpenRead(string).
istream = FtpClientInstance.OpenRead("ftp://192.168.8.99/Configuration/filename with whitespace.xml");
But then I get another exception : System.ArgumentException "The Property-Set method was not found"...

I made another empty project to test this specifically. (.NET 2.0)
What I found is, that it works in that project with the non static FtpClient.OpenRead method:
  using (FtpClient conn = new FtpClient())
            {
                conn.Host = "192.168.8.99";
                conn.Credentials = new NetworkCredential("user", "password");
                using (Stream istream = conn.OpenRead("/configuration/daily defrost configuration.ini"))
but it doesn't work with the static version of OpenRead (File Not Found):
using (Stream istream = FtpClient.OpenRead(new Uri("ftp://192.168.8.99/configuration/daily defrost configuration.ini")))