Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading the content of a FTP directory
Message
De
15/02/2012 13:26:29
 
 
À
15/02/2012 13:21:07
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01535473
Message ID:
01535489
Vues:
26
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform