Advertisement
Fhernd

SeleccionRegistros.cs

Jul 25th, 2015
21,376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. // OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7.  
  8. namespace Receta.CSharp.R0525
  9. {
  10.     public class SeleccionRegistros
  11.     {
  12.         public static void Main()
  13.         {
  14.             Console.WriteLine(Environment.NewLine);
  15.            
  16.             // Le todas las entradas en el archivo log_completo.log:
  17.             Console.WriteLine ("Mostrando todos los registros...");
  18.             IEnumerable<string> registros = File.ReadAllLines("log_completo.log");
  19.             foreach (string registro in registros)
  20.             {
  21.                 Console.WriteLine ("Registro: {0}", registro);
  22.             }
  23.            
  24.             Console.WriteLine ("\nSelección sólo registros de error...");
  25.             IEnumerable<string> registrosError = File.ReadLines("log_completo.log").Where(
  26.                 e => e.StartsWith("Error")
  27.             );
  28.             foreach (string registroError in registrosError)
  29.             {
  30.                 Console.WriteLine ("Registro error: {0}", registroError);
  31.             }
  32.            
  33.             Console.WriteLine(Environment.NewLine);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement