Reading and parsing chunks of data to end of file
Posted on 2006-07-06
I have a text file that has multiple records in it. The records are not separated by any delimiter and I know exactly how long each record will be (lets say 100 chars).
I'm grabbing sections out of the first record by parsing it and putting the results into fields like this:
There are 3 parts that I'm not sure how to do (see below). Please help.
StreamReader sr = File.OpenText(OPENFILENAME);
string contents = "";
bool finished = false;
contents = sr.ReadToEnd();
finished = true;
string membernum = contents.SubString(0,13);
string policynum = contents.Substring(14,24);
//etc to end of first record of 100 chars
//take the result and export it to a file <-- don't know how to do this
// loop using the 2nd, then 3rd etc record of 100 chars throught to the eof <-- don't know how to do this
//append the results of each record to a new file <-- don't know how to do this
What I need to do is read to the end of the first record (100 chars) parse it all out, take the result and export it to a file so that I can then begin parsing the next record into fields which I will append to the file that I'm exporting.