Your parsing of the file seems correct, only — there are no such cases when hard-coding of the file path name could be useful. I hope this is done just on a temporary basis, for fast testing.
It looks like a problem is generating the output. You need to have two nested loops: one composing a line out of per-column values, and outer loop use to output data line-by-line. And you need to store your data after parsing in some collection. It could be the collection of line data, and each line could be just an array of strings (those you obtained from the
Split
method).
For composing of a line, use the class
System.Text.StringBuilder
:
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx[
^].
Your code suffers from a number of problems. I mentioned one in the first paragraph above. Another one is this: you should declare a loop variable inside the loop:
for (int index = 0; i index < values.Length; ++index)
but you declared it before the loop, which is not good, by a number of reasons. A loop variable should only be defined inside a loop, to prevent the possibility of accessing it.
To locate and fix problems, use the debugger. This is much more efficient than asking questions. :-)
Always use the debugger
before asking questions like that. It will greatly reduce the number of questions you may want to ask, and it will improve the quality of your questions.
—SA