public void Work() { try { this.LineCount = 0; this.Invoke(new UpdateDelegate(updateStatus), 0); for (int i = 0; i < Files.Count; i++) { string file = Files.ElementAt(i); ParseFile(file); updateStatus(i+1); this.Invoke(new UpdateDelegate(updateStatus), i + 1); } this.FileOut.Close(); MessageBox.Show("Completed!\nWrote:" + this.LineCount + " lines\nOutput File:" + this.OutFile); } catch { MessageBox.Show("Aaaiiiieee!Crashed in the work thread which is impossible"); } } private void ParseFile(string file) { try { StreamReader reader = new StreamReader(file); while (!reader.EndOfStream) ParseLine(reader.ReadLine()); reader.Close(); } catch { MessageBox.Show("Aiiie!Failed to read from file!!"); } } private void ParseLine(string line) { string[] values; try { //Massive Time!!!!!!!! if (line.Trim().Length == 0) return; values = line.Split(','); } catch { MessageBox.Show("WTF!? Failed trimming or checking length"); return; } try { if (this.useEmail) if (!this.Email.Match(values[0]).Success) return; if (this.useFName) if (!this.Fname.Match(values[1]).Success) return; if (this.useLName) if (!this.Lname.Match(values[2]).Success) return; if (this.useAddress) if (!this.Address.Match(values[3]).Success) return; if (this.useCity) if (!this.City.Match(values[4]).Success) return; if (this.useState) if (!this.State.Match(values[5]).Success) return; if (this.useZip) if (!this.Zip.Match(values[6]).Success) return; if (this.usePhone) if (!this.Phone.Match(values[7]).Success) return; if (this.useURL) if (!this.URL.Match(values[8]).Success) return; if (this.useDate) if (!this.Date.Match(values[9]).Success) return; if (this.useSex) if (!this.Sex.Match(values[10]).Success) return; if (this.useCountry) if (!this.Country.Match(values[11]).Success) return; if (this.useDoB) if (!this.DoB.Match(values[12]).Success) return; if (this.useOptIn) if (!this.OptIn.Match(values[13]).Success) return; if (this.useMisc) if (!(this.Misc.Match(values[14]).Success || this.Misc.Match(values[15]).Success)) return; } catch { MessageBox.Show("Major Aiiiee! Failed checking regex!"); } //didn't fail any checks! its in! try { FileOut.WriteLine(line); } catch { MessageBox.Show("Error writing to file!"); Application.Exit(); } this.LineCount++; }