Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading the content of a FTP directory
Message
From
15/02/2012 13:26:29
 
 
To
15/02/2012 13:21:07
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01535473
Message ID:
01535489
Views:
34
>>In that case, maybe Regex can be of help - use named Groups
>>
>>Example
>>
>>After the day, I capture either a time or a year
>>
>>		static void Main(string[] args)
>>		{
>>			string[] lines =
>>			{	@"-rw-rw-rw-   1 user     group        1402 Dec 30  2005 AmazonCA.gif",
>>				@"-rwxrwxrwx   1 owner    group            4480 Feb 15  2:25 8A17T2T1.txt"
>>			};
>>
>>			string pattern = @"^(?<Permissions>\S+)\s+(?<Links>\d+)\s+(?<User>\w+)\s+(?<Group>\w+)\s+(?<FileSize>\d+)\s+(?<Month>\w+)\s+(?<Day>\d+)\s+((?<Year>\d{4})|(?<Time>\d+:\d+(:\d+)?))\s+(?<FileName>\S+)$";
>>
>>
>>
>>			foreach (string line in lines)
>>			{
>>				Match m = Regex.Match(line, pattern);
>>
>>				if (m.Success)
>>				{
>>					Console.WriteLine("Month {0}", m.Groups["Month"]);
>>					Console.WriteLine("Day {0}", m.Groups["Day"]);
>>					Console.WriteLine("Year {0}", m.Groups["Year"]);
>>					Console.WriteLine("Time {0}", m.Groups["Time"]);
>>					Console.WriteLine("FileName {0}", m.Groups["FileName"]);
>>				}
>>				else
>>					Console.WriteLine("No match");
>>
>>			}
>>
>>
>>			Console.ReadLine();
>>			return;
>>				
>>
>>		}
>>
>
>Very interesting approach, thanks for the sample

You may need to change the pattern - I just made them based on your output


This is the output I get
Month Dec
Day 30
Year 2005
Time
FileName AmazonCA.gif
Month Feb
Day 15
Year
Time 2:25
FileName 8A17T2T1.txt
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform