MainPage.xaml.cs
/// <summary>
/// return start time, End of time
/// </summary>
return start time, End of time
return start time End of time
async void ReadInfOfFile()
        {
            try
            {
                openPicker = new Windows.Storage.Pickers.FileOpenPicker();
                openPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".txt");
                Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();
                Stream stream = (await file.OpenReadAsync()).AsStreamForRead();
                streamReader = new StreamReader(stream);
                setupReadfile = true;
                Data.Time = null;
                while (null == Data.Time)
                {
                    strDataFromSerialPort = streamReader.ReadLine();
                    processDataToGetInf();
                }
                sStartTime = Data.Time;
                if (-1 != Data.Time.IndexOf('.'))
                    tblock_Start_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 6) + ':'
                            + Data.Time.Substring(Data.Time.Length - 6, 2) + ':' + Data.Time.Substring(Data.Time.Length - 4, 4);
                else
                    tblock_Start_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 4) + ':'
                            + Data.Time.Substring(Data.Time.Length - 4, 2) + ':' + Data.Time.Substring(Data.Time.Length - 2, 2);
                streamReader.BaseStream.Seek(-1, SeekOrigin.End);   
                streamReader.BaseStream.Seek(-2000, SeekOrigin.Current);
                while (streamReader.Peek() >= 0)
                {
                    strDataFromSerialPort = streamReader.ReadLine();
                    processDataToGetInf();
                }
                sStopTime = Data.Time;
                if (-1 != Data.Time.IndexOf('.'))
                    tblock_End_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 6) + ':'
                            + Data.Time.Substring(Data.Time.Length - 6, 2) + ':' + Data.Time.Substring(Data.Time.Length - 4, 4);
                else
                    tblock_End_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 4) + ':'
                            + Data.Time.Substring(Data.Time.Length - 4, 2) + ':' + Data.Time.Substring(Data.Time.Length - 2, 2);
                Data.Time = sStartTime;
                streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                streamReader = new StreamReader(stream);
                editTimeWhenChangeslider();
            }
            catch { }
        }
async void ReadInfOfFile ( ) { try { openPicker = new Windows . Storage . Pickers . FileOpenPicker ( ) ; openPicker . ViewMode = Windows . Storage . Pickers . PickerViewMode . Thumbnail ; openPicker . SuggestedStartLocation = Windows . Storage . Pickers . PickerLocationId . PicturesLibrary ; openPicker . FileTypeFilter . Add ( " " ) ; Windows . Storage . StorageFile file = await openPicker . PickSingleFileAsync ( ) ; Stream stream = ( await file . OpenReadAsync ( ) ) . AsStreamForRead ( ) ; streamReader = new StreamReader ( stream ) ; setupReadfile = true ; Data . Time = null ; while ( null == Data . Time ) { strDataFromSerialPort = streamReader . ReadLine ( ) ; processDataToGetInf ( ) ; } sStartTime = Data . Time ; if ( - 1 != Data . Time . IndexOf ( ' ' ) ) tblock_Start_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 6 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 6 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 4 ) ; else tblock_Start_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 4 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 2 , 2 ) ; streamReader . BaseStream . Seek ( - 1 , SeekOrigin . End ) ; streamReader . BaseStream . Seek ( - 2000 , SeekOrigin . Current ) ; while ( streamReader . Peek ( ) >= 0 ) { strDataFromSerialPort = streamReader . ReadLine ( ) ; processDataToGetInf ( ) ; } sStopTime = Data . Time ; if ( - 1 != Data . Time . IndexOf ( ' ' ) ) tblock_End_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 6 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 6 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 4 ) ; else tblock_End_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 4 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 2 , 2 ) ; Data . Time = sStartTime ; streamReader . BaseStream . Seek ( 0 , SeekOrigin . Begin ) ; streamReader = new StreamReader ( stream ) ; editTimeWhenChangeslider ( ) ; } catch { } }
return start time, End of time
return start time End of time
//Int32 index = 0; //format hour:min:sec //have '.' in Data.Time 82754.7 //đưa con trỏ về cuối của file //double _position = streamReader.BaseStream.Position;//lấy số ký tự của file txt //dịch con trỏ từ cuối file về lui khoảng 2000 ký tự //chúng ta sẽ đọc được thời điểm bay cuối cùng //format hour:min:sec //have '.' in Data.Time 82754.7