I'm newbie in C# so please go easy on me... basically, I'm reading through a text file and want to grab any data between two strings and store all of this data into a string / variable - how would I go about doing this?
I've already got the below but just need a push in the right direction to get me back on track.
Many Thanks
C# Code:
bool DetailsFound = false;
string[] ReadLines = File.ReadAllLines(path);
foreach (string item in ReadLines) {
if (item == "Start Details") {
DetailsFound = true;
}
if (DetailsFound) {
Console.WriteLine("Details - " + item);
// VARIABLE / STRING REQUIRED HERE
}
if (item == "End Details") {
break;
}
}
Example *.TXT File
Start Details I am line 1 I am line 2 I am line 3 End Details
Start DetailsandEnd Detailslines?List<String>.string strAllLine = string.Empty;then in if loopif (DetailsFound) { Console.WriteLine("Details - " + item); strAllLine = strAllLine + item; }so all the Line value will be stored in strAllLine string.