简体   繁体   中英

How to write in .evtx file c#

I want to write event log. I have performed a query. And its returning expected result. Now, I want to write in that result in evtx file.

here is my code:

List<EventRecord> eventList = new List<EventRecord>();
for (EventRecord eventInstance = logReader.ReadEvent();
eventInstance != null; eventInstance = logReader.ReadEvent())
{
    eventList.Add(eventInstance);
}

How to pass this eventList to write in evtx file format.

I am mentioning the code below to divide the event:

 eventRecordList = null;
 remoteEventRecordList = Xmlcollection.Cast<Control.Common.Enums.EventViewerDetails>().ToList();
 var distinctLevels = (from row in remoteEventRecordList.AsEnumerable()
                       let value = row.Level
                       select value).Distinct();
 foreach (var remoteItem in distinctLevels)
 {
     if (!AvailbleFilterOptionsObservableCollection.Any(i => i.Name == GetLevelName(Convert.ToByte(remoteItem))))
     {
         AvailbleFilterOptionsObservableCollection.Add(new FilteredData
         {
             Name = GetLevelName(Convert.ToByte(remoteItem)),
             Level = Convert.ToByte(remoteItem),
             IsSelected = true
         });
     }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM