FTP目录部分列出通配符 [英] FTP directory partial listing with wildcards

查看:200
本文介绍了FTP目录部分列出通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我问: ftp目录列表超时。巨大数量的分区。我得到了答案。

仍然因为我可以在目录中拥有数十万个FTP对象,所以扫描它可能需要很长时间。但是我认为有可能检索以'A'和'B'开头的所有对象,等等......当它检索目录时,它可以开始在另一个线程上处理它们,而不必等到它获得整个列表。

是否可以使用标准 FtpWebRequest

$ b $进行带有通配符的FTP目录列表b

解决方案

FTP规范(RFC 3659)明确禁止它。从该规范的第2.2.2节中标题为通配符(重点是我的) :


对于本规范中定义的命令,所有路径名都是
。也就是说,对于作为
a命令参数给出的路径名,其名称与给出的路径名相同的文件是
隐含的。没有任何来自路径名的字符可以被视为特殊或
魔术,因此在给定的路径名​​与$ b $的NVFS中存在的文件之间没有模式匹配(除了完全相等)
b服务器-FTP被允许。


希望某种形式的
匹配功能的客户必须获得相关
目录或目录的列表,并实现它们自己的文件名
选择程序。


也就是说,如果你的服务器支持它,你仍然可以使用 FtpWebRequest class ,但是你必须自己处理响应来处理项目列表,因为.NET类不能理解你的特定于服务器的扩展。


First I asked that: ftp directory listing timeout. Huge number of subdirs. I got the answer.

Still because I can have hundred thousands of FTP objects in the directory it could take really long time to scan that. However I thought it might be possible to retrieve all the objects that begin with 'A' and then 'B' and so on... As it retrieves directories it could start processing them on the other thread without waiting till it gets the entire list.

Is it possible to do FTP directory listing with wildcards using standard FtpWebRequest?

解决方案

The most recent update to the FTP specification (RFC 3659) explicitly forbids it. From section 2.2.2 of that specification, titled "Wildcarding" (emphasis mine):

For the commands defined in this specification, all pathnames are to be treated literally. That is, for a pathname given as a parameter to a command, the file whose name is identical to the pathname given is implied. No characters from the pathname may be treated as special or "magic", thus no pattern matching (other than for exact equality) between the pathname given and the files present in the NVFS of the server-FTP is permitted.

Clients that desire some form of pattern matching functionality must obtain a listing of the relevant directory, or directories, and implement their own file name selection procedures.

That said, if your server supports it, you could still use the FtpWebRequest class, but you'd have to process the response yourself to handle the list of items, as the .NET classes won't understand your server-specific extensions.

这篇关于FTP目录部分列出通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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