This repository has been archived on 2019-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
vn-fingerprint/LectorVerdnatura/logevent.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2018-07-26 14:16:13 +00:00
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