我想构建查询字符串以查询日期范围内的事件日志。我正在做如下。但面临无效查询错误,“指定查询无效”。我将我的查询与 Eventlog 查看器 XML 视图中提供的过滤器进行了比较。
*[System[Provider[@Name='.NET Runtime' or @Name='Application Error' or @Name='Application Hang'] and TimeCreated[@SystemTime>='2013-08-13T17:29:56.000Z'和@SystemTime<='2013-08-14T17:29:56.999Z']]]
string queryString = "*[System[Provider[@Name='Application Error' or @Name='Application Hang' or @Name='ThomsonONE' or @Name='DFContainer'] and TimeCreated[@SystemTime>='" + "2013-08-13T04:00:00.000Z" + "' and @SystemTime<='" + "2013-08-14T03:59:59.999Z" + "']]]";
EventLogQuery eventsQuery = new EventLogQuery(fileNames[0], PathType.FilePath, queryString);
EventLogReader logReader = new EventLogReader(eventsQuery);
for (EventRecord eventInstance = logReader.ReadEvent();
null != eventInstance; eventInstance = logReader.ReadEvent())
{
}
请让我知道上面的代码有什么问题?