Extracting specific parts of a line in a text file using C# : <p>I am making software to help keep track of work hours for volunteers. Right now I have a text file (with the name the same as the volunteer) that I am logging the date and time every time a someone signs in or out, like this:</p>

<pre><code>Sign In - 04/04/16 23:51:55
Sign Out - 04/05/16 00:09:48
Sign In - 04/05/16 00:09:55
</code></pre>

<p>But what i need to do is extract the date and time so i can say this volunteer worked x amount of hours on this date. This is what i have tried:</p>

<pre><code>string datetimeStringDay1In = System.IO.File.ReadLines(@"C:/users/public/Volunteers/" + Form1.selectedUser + ".txt").Skip(23).Take(1).First();
int startPosDay1In = datetimeStringDay1In.LastIndexOf("Sign In - ") + "Sign In - ".Length + 10;
int lengthDay1In = datetimeStringDay1In.IndexOf("PM") - startPosDay1In;
string SignInDay1 = datetimeStringDay1In.Substring(startPosDay1In, lengthDay1In);
</code></pre>

<p>Then doing the same for the next signout line, then moving on to doing the math. As I am sure you are already thinking this takes forever to code and limits how many entries I can have. I need a better way. I am willing to try differnet file types as long as i can read the file outside the software incase something goes wrong. At some point I am going to use a database but as of right now this is a proof of concept. After I am able to prove this saves time, money, and for some people hair, I will. Thanks you for your help.</p>
