Q:

C# Read All Lines From Specific Time to Specific Time

I am trying to get lines in a text file from a specific Start Time to specific End Time e.g. If my Range TimeSpan is FromHours(10) which is 10:00 am, the program should read all lines containing the Start Time "10:00 am" till specific Ending TimeSpan "17:00 pm". Your Help will be highly Appreciated.
Input File is like this:
2016/05/11 10:14:00 blah blah blah dah dah dah
2016/05/11 12:14:00 dah dah dah blah blah blah
2016/05/11 16:14:00 dah dah dah blah blah blah
2016/05/11 17:24:00 dah dah dah blah blah blah
The beginning of each line in file contains the date and time.
This is the code i have thus far:
   var FilePath = new DirectoryInfo("C:\\music\\playlist.txt");

     List<string> list = new List<string>();

    var StartTime = DateTime.Today.Add(TimeSpan.FromHours(10)).ToShortTimeString();

    var EndTime = DateTime.Today.Add(TimeSpan.FromHours(17)).ToShortTimeString();

       foreach (var line in FilePath )
                {
                    StreamReader read = line.OpenText();

                    while ((inside = read.ReadLine()) != null)
                    {
                        list.Add(inside);
                    };

                    string[] array = list.ToArray();        

       for (int i = 0; i < array.Length; i++)
                {
 if (array[i].Contains(StartTime) and is greater than StartTime, Display lines and stop Displaying if you find EndTime )
                    {
                         Console.WriteLine(array[i]);
                    };

            };

A:

You can try using Linq: extract the date and filter on it
var result = File
  .ReadLines(@"C:\music\playlist.txt")
  .Select(line => line.Split(new char[] {' '}, 3))
  .Select(items -> new {
     date = DateTime.ParseExact(items[0] + " " + items[1], 
                                "yyyy/M/d H:m:s", 
                                CultureInfo.InvariantCulture), 
     text = items[2]
   })
  .Where(item => item.date >= specificStartTime && 
                 item.date <= specificEndTime)
  .Select(item => string.Format("{0} {1}", 
                                item.date.ToString("yyyy/MM/dd HH:mm:ss"), 
                                item.text)); 

