0

我正在尝试在 C# 应用程序中实现 MS LogParser。这编译得很好,但在 logQuery.ExecuteBatch() 方法上莫名其妙地崩溃。try/catch 块不会捕获它,除非我专门对 szQuery 进行了错误处理,这表明一切正常,我只是没有得到任何输出。

关于为什么它可能会崩溃或我可能会在哪里找到一些日志记录的任何想法?

使用系统; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Text; 使用文件夹记录库; 使用 MSUtil;

命名空间 ConsoleApplication20 { 课堂节目 { 静态无效主要(字符串 [] 参数) { //refLog = new BinaryInputFormat(); LogQueryClass logQuery = new LogQueryClass(); ICOMCSVOutputContext 输出 = 新 COMCSVOutputContextClass(); ILogParserInputContext parse = new BinaryInputFormat();

string szFileName = @"E:\Programming\FolderLogging\2012-05-13.fbl"; string szQuery = "SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation, Checked FROM " + szFileName + " ORDER BY DateTime DESC"; try { logQuery.ExecuteBatch(szQuery, parse, output); } catch { }; } }

}

4

1 回答 1

1

Use Execute instead of ExecuteBatch:

MSUtil.ILogRecordset RecordSet = logQuery.Execute(query, oInputFormat)

If you want to export to CSV in your sample code you need to change the query by adding INTO output_file_name and run ExecuteBatch:

string szQuery = "SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation,  Checked **INTO c:\out\out.csv** FROM " + szFileName + " ORDER BY DateTime DESC";
于 2014-09-05T07:29:33.427 回答