Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code that runs
**************************************

Process process = new Process();
process.StartInfo.FileName = "C:\\Program Files\\PAGS1\\pags.exe";
process.StartInfo.Arguments = "status -v";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();

// Synchronously read the standard output of the spawned process.
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();

process.WaitForExit();
process.Close();

listBox1.Items.Add(output);
*********************************************************

My problem is that the output is one continuous (single) long line in the listBox.

If ran from command prompt, the output is displayed with 10 lines

I'd like to display the output the same way as if ran from command line. Any help is greatly appreciated
Posted
Comments
SundararamanS 10-Aug-15 8:41am    
If you are able to see '\n' new line character in your output stream then you could basically split it using '\n' as delimiter and keep adding the individual strings to the list...
j snooze 10-Aug-15 17:26pm    
the 10 line output is probably based on the width of your command prompt window. You could just break the string value up by adding a new line character(\n or Environment.NewLine) every "x" characters.
HKHerron 12-Aug-15 14:15pm    
Can you show us a sample of what the string "output" would be? Line breaks in a Command Line are different than that in a list box.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900