// OrtizOL - xCSw - http://ortizol.blogspot.com
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Receta.CSharp.R0525
{
public class SeleccionRegistros
{
public static void Main()
{
Console.WriteLine(Environment.NewLine);
// Le todas las entradas en el archivo log_completo.log:
Console.WriteLine ("Mostrando todos los registros...");
IEnumerable<string> registros = File.ReadAllLines("log_completo.log");
foreach (string registro in registros)
{
Console.WriteLine ("Registro: {0}", registro);
}
Console.WriteLine ("\nSelección sólo registros de error...");
IEnumerable<string> registrosError = File.ReadLines("log_completo.log").Where(
e => e.StartsWith("Error")
);
foreach (string registroError in registrosError)
{
Console.WriteLine ("Registro error: {0}", registroError);
}
Console.WriteLine(Environment.NewLine);
}
}
}