I am trying to automate some upload/download tasks from an ftp web server. When I connect to the server through client, or through Firefox even, in order to get to my directory, I have to specify a path like this:
ftp://ftpserver.com/../AB00000/incoming/files
If I try to access this:
ftp://ftpserver.com/AB00000/incoming/files
The server throws an error that the directory does not exist. So, the problem:
I am trying to create an FTPWebRequest with the first ftp address, but it always parses out the ‘/../’ part and then my server says the path doesn’t exist.
I’ve tried these:
Uri target = new Uri('ftp://ftpserver.com/../AB00000/incoming/files'); FtpWebRequest request = (FtpWebRequest)WebReqeuest.Create(target);
and
string target = 'ftp://ftpserver.com/../AB00000/incoming/files'; FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target);
In the first bit, the path is already incorrect when the Uri object is instantiated, in the second bit, it’s after the WebRequest.Create method. Any ideas what’s going on?
EDIT:
Additionally, since I posted this, I have tried creating the URI with the no parse option. I have also tried something like this:
string ftpserver = 'ftp://ftpserver.com/../'; string path = '12345/01/01/file.toupload'; Uri = new Uri(ftpserver, path, true);
And it always parses out the root part (‘/../’).
Try escaping the .. with something like:
That works according to this blog which I found in this discussion.