2012-10-21 21 views
5

我使用休耕代碼導出一個Windows事件日誌:異常在出口的EventLog

var els = new EventLogSession(); 
els.ExportLogAndMessages("Application", 
          PathType.LogName, 
          "*[System[Provider[@Name='Prayon.Client']]]", 
          tempEventLogPath, 
          false, 
          CultureInfo.CurrentCulture); 

這通常工作。但一臺機器上,我得到的休耕例外:

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) 

"Der Verzeichnisname ist ungültig"意味着英語:"The pathname is invalid"

的應用程序事件日誌中現有的和tempEventLogPath也是有效的。

有人知道,有什麼可能是錯的?

+0

tempEventLogPath的價值是什麼? –

回答

0

嘗試刪除目標目錄中的LocalMetaData目錄。

我有同樣的問題。 第一個調用有效,但每個後續調用都會得到上述異常。 Processmonitor的調查顯示,除了訪問目錄LocalMetaData的evtx文件之外。 刪除此目錄後,導出將再次生效。