What's the best practice reading a *.txt file and get specific regions of the text?
My *.txt files looks like:
[Product code]
MYPRODUCT-CODE123
[List price]
28.10
[Price]
20.30
[Weight]
10
[Quantity]
1
[Min quantity]
1
[Shipping freight]
N
[Free shipping]
N
[Product name]
My product name
Currently I'm reading the txt file like this:
String[] allfiles = System.IO.Directory.GetFiles(_path, "*.txt", System.IO.SearchOption.AllDirectories);
foreach (string filePath in allfiles) {
using (StreamReader sr = File.OpenText(filePath))
{
string s = sr.ReadToEnd();
}
}
How I'd get the text near [Product code], and so on for other 'key terms' from my txt file