問(wèn)題描述
FTP LIST 命令顯示當(dāng)前工作目錄中所有文件和目錄的列表.問(wèn)題是,它會(huì)根據(jù)服務(wù)器返回幾種不同的格式.有人知道能夠解析最流行格式的 .NET 庫(kù)嗎?我可以接受試試這個(gè)正則表達(dá)式,如果失敗,試試下一個(gè)正則表達(dá)式"的方法.
The FTP LIST command displays a listing of all the files and directories in the current working directory. The problem is, it returns several different formats depending on the server. Does anybody know of a .NET library that is able to parse the most popular formats? I am OK with a "try this regex, if it fails, try the next regex" approach.
推薦答案
這是我一直在使用的 FileZilla 服務(wù)器:
Here's the one that I've been using for a FileZilla server:
^(?<dir>[-ld])(?<permission>([-r][-w][-xs]){3})s+(?<filecode>d+)s+(?<owner>w+)s+(?<group>w+)s+(?<size>d+)s+(?<timestamp>((?<month>w{3})s+(?<day>d{2})s+(?<hour>d{1,2}):(?<minute>d{2}))|((?<month>w{3})s+(?<day>d{1,2})s+(?<year>d{4})))s+(?<name>.+)$
http://chrishaas.wordpress.com/2009/06/10/regex-for-parsing-ftp-list-command/
這篇關(guān)于解析來(lái)自 FTP LIST 命令的響應(yīng)(語(yǔ)法變化)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!