Hi Morten,
Thank you for responding. The old line was populated into a dataset.
One thing, though, I don't think I was clear, I need to check if a
"field" in the previous line is the same as the current "field" IF the
previous line exists.
the Text file would be something like
(the 9999999
field is the one I'm checking)
99044 Shirley Jones B12320040604 9999999
99044 John Jones B12320050604 9999999
99044 Fred Armstrong B12320040604 8888888
I read the line and parse it into a dataset, write it to a file then
read the next, append it to the file etc etc. When the number at
line.Substring(39,7) is the same as that same substring in the previous
line, I'm ADDING that person to the family rather than starting a new
family.
I can get everything to work EXCEPT that when it's the first line in
the text file, the dataset field doesn't yet exist...Hope I'm making
myself clear.
Gwenna
Morten Wennevik wrote:
Hi gwenna,
You aren't showing us how you keep track of the old line.
Anyhow, the below should give you what you need.
using (StreamReader sr = new StreamReader(F))
{
string line, oldline = null;
while ((line = sr.ReadLine()) != null)
{
if(line != oldline)
// new line, compute something
oldline = line;
}
}
--
Happy coding!
Morten Wennevik [C# MVP]