J'ai un programme simple qui lit un fichier texte de journal et essaie de l'analyser. Le programme serait en mesure de "grouper"/analyser le fichier texte de journal par "----------------------" que j'ai essayé d'utiliser la méthode ".split" mais cela ne fonctionne pas.C# Comment analyser le fichier texte en le groupant?
Fondamentalement, si possible, je voudrais que le programme de grouper le fichier texte entre chaque "----------------" à "---------- ----- "pour d'autres processus.
Quelqu'un peut-il donner des conseils sur les codes? Merci!
Mes codes:
class Program
{
static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<String> lines = File.ReadLines("C:\\Syscrawl\\new.txt");
foreach (String r in lines.Skip(7))
{
String[] token = r.Split('-');
foreach (String t in token)
{
Console.WriteLine(t);
}
}
}
}
Un échantillon du fichier pf texte;
Restore Point Info
Description : Installed Apache HTTP Server 2.2.16
Type : Application Install
Creation Time : Thu Dec 9 08:04:46 2010
C:\syscrawl\Restore\RP10\snapshot\_REGISTRY_USER_NTUSER_S-
1-5-21-1390067357-413027322-1801674531-500
Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs not found.
----------------------------------------
Restore Point Info
Description : Testing 0
Type : System CheckPoint
Creation Time : Thu Dec 9 08:05:43 2010
C:\syscrawl\Restore\RP11\snapshot\_REGISTRY_USER_NTUSER_S-
1-5-21-1390067357-413027322-1801674531-500
Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs not found.
----------------------------------------
Restore Point Info
Description : Installed Python 2.4.1
Type : Application Install
Creation Time : Thu Dec 9 08:09:12 2010
C:\syscrawl\Restore\RP12\snapshot\_REGISTRY_USER_NTUSER_S-
1-5-21-1390067357-413027322-1801674531-500
Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs not found.
----------------------------------------
Restore Point Info
Description : Installed AccessData FTK Imager.
Type : Application Install
Creation Time : Thu Dec 9 08:14:02 2010
C:\syscrawl\Restore\RP13\snapshot\_REGISTRY_USER_NTUSER_S-
1-5-21-1390067357-413027322-1801674531-500
Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs not found.
Beaucoup d'erreurs générées. La méthode "Split" ne peut pas prendre en String une variable à diviser mais seulement des tableaux. – JavaNoob
Oui, je l'ai réparé. –