Click here to Skip to main content
15,898,783 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am really struggling with formatting my text file into a datagrid. However I am confortable with my access method (random). The only trouble I am having is that data is being stored all in one line so I am finding it very difficult to format with things like streamreader as its only ouputting the entire textfile to only one record. I will show this in with an image. I would really appreciate some advice

What I have tried:

I am finding it very difficult to format with things like streamreader as its only ouputting the entire textfile to only one record.
Posted
Updated 17-Dec-17 11:54am

1 solution

If the text file is delimited with something (eg comma) then you can split the line into an array eg
var reader = new StreamReader(File.OpenRead(path));
while (!reader.EndOfStream)
{
  var line = reader.ReadLine();
  string[] LineCol;
  LineCol = line.Split(',');
}

From there you can set the columns to each part of the line.

Sorry in c#, but the princple is the same for VB
 
Share this answer
 
v2

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