我需要从日志文件中获取“运行模块”之后的词。“运行模块”之后的单词总是以句号 (.) 结尾,我需要将此单词插入数组中,以便以后需要时访问。
日志中的示例文本是:
25.5.2018 10:42:35.621 状态消息 0884:正在运行模块 SamplesSim。
25.5.2018 10:42:35.621 状态消息 0120:Data Input: Opening: T:\RCS\BiggieStatementsOn\PRINT\INPUTJACK\FCA_HomeBandAccounts_23052018.csv。(数据输入1)
我试过使用indexOf(),但我一直将“运行”作为我的输出。
这是我的代码:
string consoleOutput = compiler.StandardOutput.ReadToEnd();
startIndex = consoleOutput.IndexOf("Running module");
string[] ModuleParams;
string runningMod = "";
if (startIndex != -1)
{
lastIndex = startIndex +3;
if (lastIndex != -1)
{
ModuleParams = consoleOutput
.Substring(startIndex, lastIndex - startIndex)
.Split(' ');
runningMod = ModuleParams[0];
//.Substring(4).Replace("Running module", "").Trim();
}
Console.WriteLine(runningMod);
}
繁花如伊
相关分类