Advertisement
nexooo

Untitled

Nov 9th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. namespace xo {
  2. public partial class Form1 : Form {
  3. public Form1() {
  4. InitializeComponent();
  5. }
  6.  
  7. DirectoryInfo d = new DirectoryInfo(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Names");
  8. private void btnSearch_Click(object sender, EventArgs e) {
  9. if (txtName.Text == string.Empty) return;
  10. if (txtGender.Text == string.Empty) return;
  11. StreamWriter sw = new StreamWriter(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Parsed\" + txtName.Text + "_" + txtGender.Text + ".txt");
  12. sw.AutoFlush = true;
  13. FileInfo[] Files = d.GetFiles("*.txt");
  14. foreach (FileInfo file in Files) {
  15. StreamReader sr = new StreamReader(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Names\" + file.Name);
  16. string line;
  17. while ((line = sr.ReadLine()) != null) {
  18. string data = line;
  19. string[] parsed = data.Split(',');
  20. if (parsed[0] == txtName.Text && parsed[1] == txtGender.Text) {
  21. string year = new String(file.Name.Where(Char.IsDigit).ToArray());
  22. sw.WriteLine(year + "," + parsed[2]);
  23. break;
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement