为什么不的FtpWebRequest,或WebRequest的一般接受/../路径? [英] Why doesn't FTPWebRequest, or WebRequest in general accept a /../ path?

查看:193
本文介绍了为什么不的FtpWebRequest,或WebRequest的一般接受/../路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一些上传/下载任务从FTP Web服务器自动化。当我通过客户端连接到服务器,或通过火狐甚至,为了得到我的目录,我必须指定这样的路径:

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

如果我尝试访问此:

ftp://ftpserver.com/AB00000/incoming/files

服务器抛出该目录不存在的错误。那么,问题:

The server throws an error that the directory does not exist. So, the problem:

我试图与第一个FTP地址创建的FtpWebRequest,但它总是解析了/../部分,然后我的服务器说的路径不存在。

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.

我试过这些:

    Uri target = new Uri("ftp://ftpserver.com/../AB00000/incoming/files");
FtpWebRequest request = (FtpWebRequest)WebReqeuest.Create(target);

string target = "ftp://ftpserver.com/../AB00000/incoming/files";
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target);

在第一比特,所述路径已经是不正确时,开放的对象被实例化,在第二位,它类向WebRequest.Create方法后的。 ?任何想法是怎么回事

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?

编辑:

此外,因为我张贴了这个,我曾尝试创建URI使用no解析选项。我也尝试过这样的事情:

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 ("/../").

推荐答案

尝试逃脱。与这样的:

Uri target = new Uri("ftp://ftpserver.com/%2E%2E/AB00000/incoming/files");



根据本的blog 我在这的讨论

这篇关于为什么不的FtpWebRequest,或WebRequest的一般接受/../路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆