G
Guest
I'm using a Process object to run an external command line program that gathers cpu utilization stats. I get the output using "process.StandardOutput.ReadToEnd()" and assign it to a string variable "stats". All of that works great. The problem is when I go to parse and display the output from the program
Here's a snippet of the C# code I'm using to display the output
---------------------------------------------------
string stats = process.StandardOutput.ReadToEnd()
string[] lines = stats.Split('\n')
Console.WriteLine(stats)
for (int i=0; i < lines.Length; i++)
Console.WriteLine("Line {0}: |{1}|", i.ToString(), lines)
---------------------------------------------------
And here's the output when the code is run
---------------------------------------------------
Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
Value = Integer32 3
Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
Value = Integer32
|ine 0: |Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
|ine 1: |Value = Integer32 3
|ine 2:
|ine 3: |Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
|ine 4: |Value = Integer32
|ine 5:
Line 6: |
Here's a snippet of the C# code I'm using to display the output
---------------------------------------------------
string stats = process.StandardOutput.ReadToEnd()
string[] lines = stats.Split('\n')
Console.WriteLine(stats)
for (int i=0; i < lines.Length; i++)
Console.WriteLine("Line {0}: |{1}|", i.ToString(), lines)
---------------------------------------------------
And here's the output when the code is run
---------------------------------------------------
Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
Value = Integer32 3
Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
Value = Integer32
|ine 0: |Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
|ine 1: |Value = Integer32 3
|ine 2:
|ine 3: |Variable = host.hrDevice.hrProcessorTable.hrProcessorEntry.hrProcessorLoad.
|ine 4: |Value = Integer32
|ine 5:
Line 6: |