I am able to get first line (header) and last line of CSV
file using below code,
string lines = File.ReadAllLines(@"C:\Files\test.csv");
string firstLine = lines.First();
string lastLine = lines.Last();
string result = firstLine + "\r\n" + lastLine;
File.WriteAlltext(@"C:\Files\test_Copy.csv", result);
Now I have a same requirement for performance counter (blg)
file, but looks like File Readline
is not working for blg
file.
string line1 = File.ReadLines(@"C:\Files\BasicPerfCounters.blg").First();
The above code for reading first line of blg
won't throw any exception, but output is not
plain text,
Whereas, the first line read of csv
output is plain text,
Note - One thing I can do that I can convert blg
file to csv
file using Relog.exe
(https://blogs.technet.microsoft.com/askperf/2008/05/20/two-minute-drill-relog-exe/) and then I can easily read first line (header).
Is there any way to get first line (header) of blg
file without convert it to csv
?
Here is sample blg
file, https://github.com/Microsoft/Tx/blob/master/Traces/BasicPerfCounters.blg