I have a text file that contains a data like
ID Name Path IsTrue Period
1 "1 yr" "C:\\Program Files\\My File.xyz" -1 2"
1 "1 yr" "C:\\Program Files\\My File.xyz" -1 2"
now I have the following code to split the line
string[] ArrSeperators = { " " };
ArrSplitStrs = CurrStr.Split(ArrSeperators,
StringSplitOptions.RemoveEmptyEntries);
CurrStr represents each line of text file.
The problem is it split the name and path into multiple string but they must be treated as a single string. I cannot make any changes to file as it is a standard file across different products.
I am not getting what I can do.
Use an algorithm like this:
Process each character of each line one at a time.
Count every ” that you find.
If the number of “s is odd, you know that you need to keep reading the current field until you hit another “.
If the number of “s is even, you know that as soon as you hit a space you’re on to the next field.
Something like (this may have errors – I’ve just written it off the top of my head):
EDIT:
Here’s a hacky example that works for your sample – the GetFields method needs some refactoring and it’s far from the quality of anything I’d put in my code, but the basic principle is there.