ftp-clientfileparsingfileparse

Parsing File details for Windows FTP Server


I am trying to connect to FTP server through the c# code and I am getting the list of Files and directories. And that I am saving in a ArrayList(with all attributes). I can find the FTP Server type through the SYS ftp command. I have a regular expression for UNIX based files to parse the file\directories attributes. But I have no expression for Windows FTP server files parsing. I need help in making that..

04-30-09  10:40AM       <DIR>          Acrobat
12-08-09  10:36PM                 9058 AuthCheck.zip
12-06-09  12:49PM                  174 desktop.ini
11-09-09  03:33PM       <DIR>          FailedPDF

I need to parse these. Date, Time, Dir\File, Name of the file

Please help. Thanks.


Solution

  • I don't know much about C#, but if you just need a RegEx try this one:

    ^(\d\d-\d\d-\d\d)\s+(\d\d:\d\d(AM|PM))\s+([\w<>]*)\s+(\d*)\s+([\w\._\-]+)\s*$

    $1 = date, $2=time, $3=am or pm, $4=type (could be null), $5=size(null if dir), $6=name

    or iff $4 is only or empty

    ^(\d\d-\d\d-\d\d)\s+(\d\d:\d\d(AM|PM))\s+(<DIR>)?\s+(\d*)\s+([\w\._\-]+)\s*$

    I suppose that "<" and ">" are no special chars at c#