How to read .ETL files in .Net?

How to read .ETL files in .Net? I want to see my etl file in a list view, but I cannot parse the contents of the file since it is not ascii.

+3
source share
2 answers

Nothing, I figured this out using various google searches. here is how i did it:

    //Init
    System.Diagnostics.Process worker = new System.Diagnostics.Process();
    //Start logging
    worker.StartInfo.FileName="logman";
    worker.StartInfo.Arguments="start MyTcpipLog -p Microsoft-Windows-TCPIP -ets";
    worker.Start();
    worker.WaitForExit();
    //Do nothing for 30 seconds
    DateTime start = DateTime.Now;
    while(DateTime.Now.Subtract(start).Seconds<5){}
    //Stop logging
    worker.StartInfo.FileName="logman";
    worker.StartInfo.Arguments="stop MyTcpipLog -ets";
    worker.Start();
    worker.WaitForExit();
    //Convert .etl to .csv
    worker.StartInfo.FileName="tracerpt";
    worker.StartInfo.Arguments = "\""+System.IO.Path.GetDirectoryName(Application.ExecutablePath)+"\\MyTcpipLog.etl\" -o \""+System.IO.Path.GetDirectoryName(Application.ExecutablePath)+"\\MyTcpipLog.csv\"";
    worker.Start();
    worker.WaitForExit();
    //Load CSV into memory
    // create reader & open file
    System.IO.TextReader tr = new System.IO.StreamReader("MyTcpipLog.csv");
    string data = tr.ReadToEnd();
    tr.Close();
    //Delete CSV
    System.IO.File.Delete("MyTcpipLog.etl");
    System.IO.File.Delete("MyTcpipLog.csv");
+2
source

You can probably use the P / Invoke and WinAPI OpenTrace and ProcessTrace functions. See MSDN for some C code example.

+2
source

All Articles