與讀取按照以下格式此C#:行= StreamReader.ReadLine <=項目
2014/11/03 14:31:03 PID:8696 UUID:2ae855da-37d1-4a99-8510-27539afa09d0 Start E:/I3/IC/Logs/2014-11-03/SIPEngine_2.ininlog
2014/11/04 00:00:01 PID:8696 UUID:2ae855da-37d1-4a99-8510-27539afa09d0 End E:/I3/IC/Logs/2014-11-03/SIPEngine_2.ininlog
我已經剝離出來的時候在一個變量,但需要獲得能夠在文件中搜索一個文件工作任何小於或等於該值
由於@dbc
現在我需要獲得最新的比賽
while (reader.next(msg, control))
{
ActiveAttributesVect_t attribs = msg.get_active_context_attributes();
ActiveAttributeValuesVect_t attribVals = msg.get_active_context_attribute_values();
int numAttribs = ((attribs != null) && (attribVals != null)) ? Math.Min(attribs.Count, attribVals.Count) : 0;
for (int i = 0; i < numAttribs; ++i)
{
if (attribVals[i].ToString().Contains(strCallID))
{
callidList.Add(msg.expand_format_message());
// Setting the date to match the log format
strCallDate = msg.timestamp().as_creator_time(header.tz_offset()).ToString().Substring(0, 10).Replace("-", "/");
strCallTime = msg.timestamp().as_creator_time(header.tz_offset()).ToString().Substring(11, 8);
Console.WriteLine("Call Time : {0}", strCallTime);
Console.WriteLine("Call Date : {0}", strCallDate);
Console.WriteLine("");
foreach (var entry in callidList)
{
Console.WriteLine(entry);
}
Console.WriteLine("");
OutputLogLinesBeforeTime(strLogDirectory, msg.timestamp().as_creator_time(header.tz_offset()), strCallTime);
}
}
旁註:你沒有關閉您的文件,據我可以看到。你甚至不需要StreamReader,看看'System.IO.File.ReadLines(string fileName)'。 – 2014-11-04 22:09:29
那麼你的問題是什麼? – 2014-11-04 22:10:13
在裁剪出的時間內使用['DateTime.Parse()'](http://msdn.microsoft.com/zh-cn/library/system.datetime.parse%28v=vs.110%29.aspx)那麼只需使用[比較運算符](http://msdn.microsoft.com/zh-cn/library/ff986512%28v=vs.110%29.aspx)作爲DateTime。 – dbc 2014-11-04 22:10:51