public List <UsbFileSummary> GetVoiceRecordsFromStorage() { FileInfo[] recordFiles = GetAllViableFilesInRecordFolder(); recordFiles = recordFiles.OrderBy(a => a.CreationTime).ToArray(); SavedRecordings = new Dictionary <DateTime, List <FileInfo> >(); foreach (FileInfo recordFile in recordFiles) { DateTime fileCreationDate = recordFile.CreationTime.Date; if (SavedRecordings.ContainsKey(fileCreationDate)) { SavedRecordings[fileCreationDate].Add(recordFile); } else { List <FileInfo> infoList = new List <FileInfo> { recordFile }; SavedRecordings[fileCreationDate] = infoList; } } UsbFileSummary summary = new UsbFileSummary(); List <UsbFileSummary> fileSummaries = SavedRecordings.Select(a => summary.CreateSummaryFromFileList(a.Key, a.Value)).ToList(); return(fileSummaries); }
public UsbFileSummary CreateSummaryFromFileList(DateTime date, List <FileInfo> fileInfos) { UsbFileSummary summary = new UsbFileSummary(); string dateToString = date.ToString(@"dd-MMM-yyyy"); summary.ColumnOne = "RecordingsDated-" + dateToString; summary.ColumnTwo = fileInfos.Count.ToString(); long totalSize = fileInfos.Select(a => a.Length).Sum(); totalSize = totalSize / 1000; summary.ColumnThree = $"{string.Format("{0:0.00}", totalSize)}kbs"; summary.ColumnFour = "Upload"; summary.ColumnFive = "UploadRecording--" + date.ToString(); return(summary); }