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:21:07
 
 
To
15/02/2012 13:15:16
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:
01535487
Views:
33
>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
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform