@Al S , Welcome to Microsoft Q&A, you could use the index of start token and end token to get a section of textfile.
Here is a code example you could refer to.
var file = File.ReadAllLines("test.txt").ToList();
int startindex = file.IndexOf("2D FILES");
int endindex = file.IndexOf("END");
var result = file.Skip(startindex + 1).Take(endindex-startindex-1);
Dictionary<string, int> dic = new Dictionary<string, int>();
foreach (var item in result)
{
dic.Add(item.Split(' ')[0], Convert.ToInt32(item.Split(' ')[1]));
}
foreach (var item in dic)
{
Console.WriteLine("key is {0} and value is {1}",item.Key,item.Value);
}
Tested result:
Hope this could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.