J
JC
I'm trying to create a GUI wrapper for dumpbin, and so I'm using the Process
class to run the command-line application. The problem is that if I use
Readline() to get the output from the commandline app, it will hang when it
comes to the command-prompt (there's no return to send it to readline).
Here's the code:
public bool RunCommands(string cmds, ArrayList files)
{
try
{
StreamReader sr = VSCmd.StandardOutput; // VSCmd is the Process
object running cmd.
string s;
string t = "";
foreach(string file in files)
{
stWriter.WriteLine("Dumpbin" + cmds + " " + file);
while ((s=sr.ReadLine())!=null) // When Dumpbin runs once,
it finishes with a prompt; application will hang here waiting for a return.
t += s;
}
System.Windows.Forms.MessageBox.Show(t);
return true;
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("Error in
CVSCmdPrompt.RunCOmmands: " + e.ToString());
return false;
}
}
I want to loop through the files for various reasons, so I don't want to
wait for the Process to shut down. Also, i've noticed that if i don't
redirect the output to the process, Visual Studio sends it to the Output
screen anyway! And it doesn't hang at the prompt. How does it do this? Can I
tap this?
Thanks
Josh
class to run the command-line application. The problem is that if I use
Readline() to get the output from the commandline app, it will hang when it
comes to the command-prompt (there's no return to send it to readline).
Here's the code:
public bool RunCommands(string cmds, ArrayList files)
{
try
{
StreamReader sr = VSCmd.StandardOutput; // VSCmd is the Process
object running cmd.
string s;
string t = "";
foreach(string file in files)
{
stWriter.WriteLine("Dumpbin" + cmds + " " + file);
while ((s=sr.ReadLine())!=null) // When Dumpbin runs once,
it finishes with a prompt; application will hang here waiting for a return.
t += s;
}
System.Windows.Forms.MessageBox.Show(t);
return true;
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("Error in
CVSCmdPrompt.RunCOmmands: " + e.ToString());
return false;
}
}
I want to loop through the files for various reasons, so I don't want to
wait for the Process to shut down. Also, i've noticed that if i don't
redirect the output to the process, Visual Studio sends it to the Output
screen anyway! And it doesn't hang at the prompt. How does it do this? Can I
tap this?
Thanks
Josh