如何从FTP服务器使用C#获取一个范围的文件 [英] how to fetch a range of files from an FTP server using C#
问题描述
我被困在一个点,我使用的对象的FtpWebRequest通配符参数作为吸
i'm stuck at a point where i am using a wildcard parameter with the FtpWebRequest object as suck
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + WildCard));
现在这工作正常,但是我现在想获取文件的特定范围。
now this works fine, however i now want to fetch a specific range of files.
说,该文件的命名结构是 *年月日。*
,我需要先获取所有文件到今天的日期。
say the file naming structure is *YYYYMMDD.*
and i need to fetch all the files prior to today's date.
我一直在寻找的那个没有很好的效果,人们将在一个简单的文件清单工作通配符模式。
i've been searching for a wildcard pattern for that with no good results, one that will work in a simple file listing.
和它看起来并不像我可以在这里使用正则表达式。
and it doesn't look like i can use regex here.
有什么想法?
推荐答案
该FTP RETR
(检索)命令不支持通配符
The FTP RETR
(retrieve) command does not support wild cards.
您将获得一个列表
所有文件,遍历它们,只检索后面的那些你需要的模式。
You will have to get a LIST
of all files, loop over them and retrieve only the ones that follow the pattern you need.
RFC 959 没有指定外卡,而只是陈述一个<路径方式>
应传递到 RETR
命令
RFC 959 does not specify wild cards, but simply states a <pathname>
should be passed to the RETR
command.
这篇关于如何从FTP服务器使用C#获取一个范围的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!