Click here to Skip to main content
15,900,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
i am working on wpf application and in this im exportin evtx files using ExportLogAndMessages function.

and it is fetching all the data but now i want to fetch the events only between of selected time period so please tell me how to write query to get event which are created in particular time span.
TIA

What I have tried:

below is my code for fetching all evtx files

logsession.ExportLogAndMessages(LogName, PathType.LogName, "*", subfolderpath, false, CultureInfo.CurrentCulture);


how to write query for selected time span.
Posted
Updated 26-Nov-17 21:56pm

1 solution

 
Share this answer
 
Comments
sumitk.cadc 28-Nov-17 0:15am    
Hi Richard,
can you please tell me how to pass query in above method for time span. i am writing like below but it is saying invalid query.

if (EventLog.Exists(LogName))
{
EventLogSession logsession = new EventLogSession();
logsession.ExportLogAndMessages(LogName, PathType.LogName, "*[TimeCreated[@SystemTime>='2017-11-28T02:49:35.000Z' and @SystemTime<='2017-11-28T03:50:51.999Z']]", subfolderpath, false, CultureInfo.CurrentCulture);

}
Richard MacCutchan 28-Nov-17 3:51am    
You cannot compare a DateTime value to a string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900