Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从eventlog中删除一个事件(或将EventRecord强制转换为EventLogEntry)_C#_.net_Events_System.diagnostics_Event Viewer - Fatal编程技术网

C# 从eventlog中删除一个事件(或将EventRecord强制转换为EventLogEntry)

C# 从eventlog中删除一个事件(或将EventRecord强制转换为EventLogEntry),c#,.net,events,system.diagnostics,event-viewer,C#,.net,Events,System.diagnostics,Event Viewer,我的代码筛选来自远程PC的事件,以测试是否存在一些6008(意外重新启动)事件 我使用的代码如下: EventLog log = new EventLog("System",remoteMachine); EventLogEntryCollection entries = log.Entries; var entries_filtered = entries.Cast<EventLogEntry>().Where (x => x.EventID=6008); foreach (

我的代码筛选来自远程PC的事件,以测试是否存在一些
6008(意外重新启动)
事件

我使用的代码如下:

EventLog log = new EventLog("System",remoteMachine);
EventLogEntryCollection entries = log.Entries;
var entries_filtered = entries.Cast<EventLogEntry>().Where (x => x.EventID=6008);
foreach (EventLogEntry entry in entries) {//my logic here}
我需要找到一种方法,将
EventRecord
转换为
EventLogEntry
,或将
EventReader
转换为
EventLogEntryCollection
以消除更改下面整个逻辑的需要

对这两个案子有什么想法吗

谢谢

EventLogReader elr = new EventLogReader("C:\\myevents.evtx");    
EventRecord a = elr.ReadEvent();