FtpClient.OpenRead(uri) and Uri with whitespaces

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


following code:
string dummy = " 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
500 Unrecognized command
Text encoding: System.Text.ASCIIEncoding
200 Switching to binary mode
SIZE /Configuration/Consumption%20Counter.ini
550 File not found
500 Unrecognized command
227 Entering passive mode (192,168,8,99,5,128)
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(" 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 = "";
                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(" defrost configuration.ini")))