을하는 데 도움이
Dim yourString as string
Dim words as string()
Do While objReader.Peek() <> -1
yourString = objReader.ReadLine()
words = yourString.split(" ")
For Each word in words()
If Myword = word Then
do stuff
End If
Next
Loop
희망 뭔가 될 것이다 :
StreamReader sr;
string fileContents;
string[] logFiles = Directory.GetFiles(@"C:\Logs");
foreach (string file in logFiles)
{
using (StreamReader sr = new StreamReader(file))
{
fileContents = sr.ReadAllText();
if (fileContents.Contains("ACTION:") || fileContents.Contains("INPUT:") || fileContents.Contains("RESULT:"))
{
// Do what you need to here
}
}
}
정확한 구현 요구 사항에 따라 몇 가지 변형을해야 할 수 있습니다 (예 : 단어가 두 줄에 걸쳐 있고 단어가 단어로 시작해야하는지 등).
추가
대체 라인 별 검사 :
이
StreamReader sr;
string[] lines;
string[] logFiles = Directory.GetFiles(@"C:\Logs");
foreach (string file in logFiles)
{
using (StreamReader sr = new StreamReader(file)
{
lines = sr.ReadAllLines();
foreach (string line in lines)
{
if (line.Contains("ACTION:") || line.Contains("INPUT:") || line.Contains("RESULT:"))
{
// Do what you need to here
}
}
}
}
출처
2011-08-25 00:03:24
Tim
10KB는 정말 작습니다. 메모리가 너무 커서/ – NullUserException