using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace WindowsFormsApp1 { public partial class fileSearcher : Form { string lineReaderOriginal; string lineReaderEdited; string scratchPad; string year; string month; string day; string searchingFor; string shortList; String[] all = Directory.GetFiles(@"C:\Some Folder", "*.txt", SearchOption.AllDirectories); public fileSearcher() { InitializeComponent(); } private void searchButton_Click(object sender, EventArgs e) { shortList = ""; for (int i = 0; i < all.Length; i++) { //making the data, in the present "all" array spot, readable StreamReader source = new StreamReader(all[i]); while (source.Peek() != -1) { if (searchingFor == source.ReadLine()) { lineReaderOriginal = source.ReadLine(); lineReaderEdited = lineReaderOriginal; if (searchTextBox.Text.Length == 10) { year = searchTextBox.Text.Remove(4, searchTextBox.Text.Count() - 4); scratchPad = searchTextBox.Text.Remove(0, 4); scratchPad = scratchPad.Remove(0, 1); month = scratchPad.Remove(2, scratchPad.Count() - 2); day = searchTextBox.Text.Remove(0, 8); if (lineReaderEdited.Length == 10) { if (year == lineReaderEdited.Remove(4, searchTextBox.Text.Count() - 4)) { scratchPad = scratchPad.Remove(2, 3); if (String.Equals(month, scratchPad)) { if (String.Equals(day, lineReaderEdited.Remove(0, 8))) { shortList += lineReaderOriginal + "\t\t" + all[i].Remove(0, 28) + Environment.NewLine + Environment.NewLine; } } } } } } } } MessageBox.Show($"{shortList}"); } private void searchComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (searchComboBox.Text == "Commitment to Others") { searchingFor = "ctoTextBox"; } else if (searchComboBox.Text == "Commitment to Self") { searchingFor = "ctsTextBox"; } } } }