It's a source file in VS2010 and it's currently used to load some static data. Now the amount of data has grown so we are considering holding the data in txt files. That way it can be easily modified. I need some way to read this data into the program from my text files that
look like this:

> test1
aaa
bbb
ccc
> test2
ddd
eee
fff

The code needs to read in the test1 into a variable, read in and add the following lines to nD
until the blank line. At that point it needs to do some action. Then it needs to start again reading in test2.

Actually there is a lot more to this but I hope someone can give me some advice to get me started on reading data from a file in a loop until some point when I can restart the loop.

I prefer the latter two, for a number of reasons. In your case, I would suggest xaml serialization, as if you set the build to Page, and use your namespaces (xmlns) correctly (you'll see them defined when you open a serialized file) you'll get intellisense in VS as you edit the files. Helpful.

Please note, all code is c#-like pseudocode and may need debugging/syntax editing before they work correctly.

Gotta wrap this kind of thing in a using block, to ensure it's closed properly, like: using (var file = new StreamReader(fileName)) { /* Do all the file reading stuff */ }
–
Joe EnosAug 7 '11 at 16:55

@Joe - agreed, and I wondered about that, but thought that someone asking how a file should be read might want a simpler example not layering the good practice of 'using'. But you're right - so I've edited the answer
–
iandotkellyAug 7 '11 at 17:02