我使用fallowing代码导出Windows-Event-Log:
var els = new EventLogSession();
els.ExportLogAndMessages("Application",
PathType.LogName,
"*[System[Provider[@Name='Prayon.Client']]]",
tempEventLogPath,
false,
CultureInfo.CurrentCulture);
Run Code Online (Sandbox Code Playgroud)
这通常有效.但在一台机器上,我得到了一个例外:
System.Diagnostics.Eventing.Reader.EventLogException: Der Verzeichnisname ist ungültig
bei System.Diagnostics.Eventing.Reader.EventLogException.Throw(Int32 errorCode)
bei System.Diagnostics.Eventing.Reader.NativeWrapper.EvtArchiveExportedLog(EventLogHandle session, String logFilePath, Int32 locale, Int32 flags)
bei System.Diagnostics.Eventing.Reader.EventLogSession.ExportLogAndMessages(String path, PathType pathType, String query, String targetFilePath, Boolean tolerateQueryErrors, CultureInfo targetCultureInfo)
Run Code Online (Sandbox Code Playgroud)
"Der Verzeichnisname ist ungültig" 意思是英语: "The pathname is invalid"
Application-EventLog是现有的,tempEventLogPath也是有效的.
有人知道,有什么可能是错的吗?
小智 0
尝试删除目标目录中的LocalMetaData目录。
我有同样的问题。第一个调用有效,但随后的每个调用都会出现上述异常。对 Processmonitor 的调查表明,除了 evtx 文件之外,还可以访问 LocalMetaData 目录。删除此目录后,导出将再次起作用。