50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
|
using System;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.IO;
|
|||
|
using System.Collections;
|
|||
|
|
|||
|
namespace LectorVerdnatura
|
|||
|
{
|
|||
|
static class logevent
|
|||
|
{
|
|||
|
|
|||
|
const string sSource="Lector";
|
|||
|
const string sLog="Application";
|
|||
|
const string fic = @"c:\temp\logfichajes.txt";
|
|||
|
|
|||
|
public static void logeventwrite(String sEvent)
|
|||
|
{
|
|||
|
if (!EventLog.SourceExists(sSource))
|
|||
|
EventLog.CreateEventSource(sSource, sLog);
|
|||
|
EventLog.WriteEntry(sSource, sEvent);
|
|||
|
EventLog.WriteEntry(sSource, sEvent,
|
|||
|
EventLogEntryType.Warning, 234);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static void logeventwritefile (String texto)
|
|||
|
{
|
|||
|
System.IO.StreamWriter sw = new System.IO.StreamWriter(fic, true); //anexo al fichero
|
|||
|
sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + texto);
|
|||
|
sw.Close();
|
|||
|
}
|
|||
|
|
|||
|
public static ArrayList leerlog()
|
|||
|
{
|
|||
|
string sLine = "";
|
|||
|
StreamReader objReader = new StreamReader(fic);
|
|||
|
ArrayList arrText = new ArrayList();
|
|||
|
|
|||
|
while (sLine != null)
|
|||
|
{
|
|||
|
sLine = objReader.ReadLine();
|
|||
|
if (sLine != null)
|
|||
|
arrText.Add(sLine);
|
|||
|
}
|
|||
|
objReader.Close();
|
|||
|
return arrText;
|
|||
|
}
|
|||
|
|
|||
|
}//clase
|
|||
|
}//namespace
|