Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Text File into Structure Array

Status
Not open for further replies.
Aug 1, 2003
39
US
I am trying to read a text file which has been read by a StreamReader and get the info into a Structure Array. There is a catch. The text file has no delimted characters and has a Carriage Return/Line Feed at the end of each line. The first line is Someones Name, The second line is the Address only of the first line, etc. How do I read the file into an Array Structure by going to the next line in the StreamReader to place the next line of data in the next Field of the Structure Array?

.



--------------------------
Thanks
Brian

 
How do you know when all the lines for a given person/address have been read? If there is no answer to this then what you wish to do is impossible.

If however there is a way then it's quite straightforward.(examples include a blank line, a line containing some explicit value or simply that there are always, say, 6 lines for every user (the most likely))

To take the last case as an example you start with the first line and store it in the Name element of the structure, the second line goes into the Address line 1 of the structure etc.

When the last line for a person has been read and stored in the structure, save the structure in some way and treat the next line as the Name.

Repeat until the end of the stream.


Bob Boffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top