Brian
asked on
How to copy a StreamReader to a List(of string) in VB.net
Is there a way to copy a StreamReader to a List without using a loop? I have the following code where I copy it to a textbox, but I would like to copy it to a List to remove some of the lines before outputting it to my textbox.
Dim SR As System.IO.StreamReader = CMDprocess.StandardOutput
'run some commandline stuff
OutputTextBox.AppendText(SR.ReadToEnd) 'this works and outputs the lines of text to the textbox
'I'd like to do something like this
Dim strOutput As List(Of String)
strOutput.Add(SR.ReadToEnd) 'this does not work
Is there a way I can copy the contents of SR to strOutput without using a loop?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help!
ASKER
1. Don't start outputting what is in SR until I reach a line that contains "Port Description".
2. Keep outputting each line to the textbox until a line is reached that contains "Oob Type".
I have the following code that outputs what I want, but maybe someone can give me some tips on how to clean it up a little and make it more concise. I'm not a professional programmer, just a dabbler, so I'm sure the code could be done better. Thanks!
Open in new window