how to fetch a range of files from an FTP server using C#

。_饼干妹妹 提交于 2019-12-11 02:51:11

问题


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.

any thoughts ?


回答1:


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 does not specify wild cards, but simply states a <pathname> should be passed to the RETR command.



来源:https://stackoverflow.com/questions/2616327/how-to-fetch-a-range-of-files-from-an-ftp-server-using-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!