0

I'm trying to read a BLG file from my application. I can read a CSV file from my application, but I also want to add another form to convert a BLG file to CSV. Unfortunately I'm getting an error that it says file cannot be found. Here is the code:

    object command;
    string dosyaAdi; 

    private void btnCevir_Click(object sender, EventArgs e)
    {
        try
        {
            dosyaAdi = openFileDialog1.FileName;
            command = "relog "+dosyaAdi+".blg -f CSV -o "+dosyaAdi+".csv";
                System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                procStartInfo.CreateNoWindow = true;
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();
                string result = proc.StandardOutput.ReadToEnd();
                MessageBox.Show(result);
        }
        catch (Exception objException)
        {

        }
    }

Thank you for your help.

MeanGreen
  • 3,098
  • 5
  • 37
  • 63
Mert Gumru
  • 11
  • 6
  • Can you post more details? What is the exact error? What is the value of 'command'? – MeanGreen Sep 02 '14 at 11:35
  • @MeanGreen the exact error is,after I get the BLG file I click on a button to convert it,but it says that it's unable to find the specified file. – Mert Gumru Sep 02 '14 at 11:42
  • This probably means the code is not looking in the location you expect. What is the value of 'command' before the error? – MeanGreen Sep 02 '14 at 11:50
  • Are there spaces in path (dosyaAdi variable) ? If there are spaces in path, you have to enquote the path i.e. relog c:\Program Files\ has to be relog "c:\Program Files" – Ondrej Svejdar Sep 02 '14 at 12:00
  • It is, but it can be cast to string. You could even define it as a string. What is the result of command.ToString() ? – MeanGreen Sep 02 '14 at 12:41
  • Unfortunately the result is still the same – Mert Gumru Sep 02 '14 at 13:05

1 Answers1

1

I would just use the parser from Tx (LINQ to Logs and Traces), it is a C# library that supports multiple trace formats, blg, csv, tsv included.

And that is the usage:

var playback = new Playback();

playback.AddPerfCounterTraces(@"C:\bin\Release\Net40\BasicPerfCounters.blg");

playback
    .GetObservable<PerformanceSample>()
    .Dump();

playback.Run();

You can also find examples how to use it in Tx samples for LINQpad:

enter image description here