Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace xo {
- public partial class Form1 : Form {
- public Form1() {
- InitializeComponent();
- }
- DirectoryInfo d = new DirectoryInfo(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Names");
- private void btnSearch_Click(object sender, EventArgs e) {
- if (txtName.Text == string.Empty) return;
- if (txtGender.Text == string.Empty) return;
- StreamWriter sw = new StreamWriter(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Parsed\" + txtName.Text + "_" + txtGender.Text + ".txt");
- sw.AutoFlush = true;
- FileInfo[] Files = d.GetFiles("*.txt");
- foreach (FileInfo file in Files) {
- StreamReader sr = new StreamReader(@"C:\Users\xxxxxxxxxxx\Desktop\susan is cute\Names\" + file.Name);
- string line;
- while ((line = sr.ReadLine()) != null) {
- string data = line;
- string[] parsed = data.Split(',');
- if (parsed[0] == txtName.Text && parsed[1] == txtGender.Text) {
- string year = new String(file.Name.Where(Char.IsDigit).ToArray());
- sw.WriteLine(year + "," + parsed[2]);
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement