M
MuZZy
Hi,
I just wonder if anybody could help me with this:
I have a WinForms app which by pressing a button creates a process invoking lame.exe to convert a wave file to mp3.
The process is launcghed in a separate thread.
I need to be able to read the console to update the progressBar on the form with current percentage of conversion.
The problem is that it returns blank if i read from standard output
Here's the code:
// ================== CODE START =============================
string lame_param = String.Format(" -b32 -mm {0} {1}", WavFileToEnc, Mp3FileName);
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo("lame.exe", lame_param);
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
//psi.CreateNoWindow = true;
p.StartInfo = psi;
try
{
p.Start();
StreamReader reader = p.StandardOutput;
string s = "";
while (!p.HasExited)
s += reader.ReadLine();
// I ALSO TRIED s = reader.ReadToEnd(); - same result
p.WaitForExit();
}
finally
{
p.Close();
}
// ================== CODE END ===============================
The value of string "s" stays blank for all the time, but lame obviousely makes an output
Any ideas would be highly appreciated!
Thank you,
Andrey
I just wonder if anybody could help me with this:
I have a WinForms app which by pressing a button creates a process invoking lame.exe to convert a wave file to mp3.
The process is launcghed in a separate thread.
I need to be able to read the console to update the progressBar on the form with current percentage of conversion.
The problem is that it returns blank if i read from standard output
Here's the code:
// ================== CODE START =============================
string lame_param = String.Format(" -b32 -mm {0} {1}", WavFileToEnc, Mp3FileName);
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo("lame.exe", lame_param);
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
//psi.CreateNoWindow = true;
p.StartInfo = psi;
try
{
p.Start();
StreamReader reader = p.StandardOutput;
string s = "";
while (!p.HasExited)
s += reader.ReadLine();
// I ALSO TRIED s = reader.ReadToEnd(); - same result
p.WaitForExit();
}
finally
{
p.Close();
}
// ================== CODE END ===============================
The value of string "s" stays blank for all the time, but lame obviousely makes an output
Any ideas would be highly appreciated!
Thank you,
Andrey