我有這樣的 輸入數據文件類型數據的文本文件得到specfic行:INdia.Txt如何在C#中的文本文件
INdia(s) - Input Data File Exists .....
**------------------------------------------**
Feed Counts:
**------------------------------------------**
Records in the Input File : 04686
Records Inserted in Table : 04069
Records Inserted in Table : 00617
**-------------------------------------------**
我需要在輸出文件中只得到這個數據
Records in the Input File : 04686
Records Inserted in Table : 04069
Records Inserted in Table : 00617
代碼我使用
try
{
int NumberOfLines = 15;
string[] ListLines = new string[NumberOfLines];
using (FileStream fs = new FileStream(@"d:\Tesco\NGC\UtilityLogs\Store.log", FileMode.Open))
{
using (StreamReader reader = new StreamReader(fs, Encoding.UTF8))
{
string line = null;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
if (line.Contains("Records"))
{
//Read the number of lines and put them in the array
for (int i = 8; i < NumberOfLines; i++)
{
ListLines[i] = reader.ReadLine();
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
有這方面的幫助將是巨大
感謝 王子
Ha!這很棒!從我+1。 –