解析FtpWebRequests ListDirectoryDe​​tails线 [英] Parsing FtpWebRequests ListDirectoryDetails Line

查看:297
本文介绍了解析FtpWebRequests ListDirectoryDe​​tails线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助与分析从ListDirectoryDe​​tails在C#中的响应。
我只需要以下字段。
文件名/目录名
创建日期
和文件的大小。

I need some help with parsing the response from ListDirectoryDetails in c#. I only need the following fields. File Name/Directory Name Date Created and the File Size.

下面就是一些线看,当我运行像ListDirectoryDe​​tails

Here's what some of the lines look like when i run ListDirectoryDetails

d--x--x--x    2 ftp      ftp          4096 Mar 07  2002 bin
-rw-r--r--    1 ftp      ftp        659450 Jun 15 05:07 TEST.TXT
-rw-r--r--    1 ftp      ftp      101786380 Sep 08  2008 TEST03-05.TXT
drwxrwxr-x    2 ftp      ftp          4096 May 06 12:24 dropoff

在此先感谢

推荐答案

不知道你还需要这一点,但是这是我想出了一个解决方案:

Not sure if you still need this, but this is the solution i came up with:

Regex regex = new Regex ( @"^([d-])([rwxt-]{3}){3}\s+\d{1,}\s+.*?(\d{1,})\s+(\w+\s+\d{1,2}\s+(?:\d{4})?)(\d{1,2}:\d{2})?\s+(.+?)\s?$",
    RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace );



匹配组:

Match Groups:


  1. 对象类型:

    • D:目录

    • - :文件

这篇关于解析FtpWebRequests ListDirectoryDe​​tails线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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