Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Threading;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- Thread t1 = null;
- List<string> path;
- List<long> sizeFile;
- long SizeAllFile;
- DirectoryInfo source;
- public Form1()
- {
- InitializeComponent();
- // st = new Stopwatch();
- path = new List<string>();
- sizeFile = new List<long>();
- SizeAllFile = 0;
- load();
- }
- public void load()
- {
- source = new DirectoryInfo(@"E:\Text");
- FileInfo[] files = source.GetFiles();
- foreach (FileInfo f in files)
- {
- path.Add(source.FullName +"\\"+ f.Name);
- sizeFile.Add(f.Length);
- SizeAllFile += f.Length;
- }
- }
- public int find(string path)
- {
- int c = 0;
- StreamReader streamReader = new StreamReader(path);
- String s= streamReader.ReadToEnd();
- streamReader.Close();
- for (int i = 0; i < s.Length; i++)
- {
- if (s[i] == 'o' || s[i] == 'O')
- c++;
- if (s[i] == 'i' || s[i] == 'I')
- c++;
- if (s[i] == 'U' || s[i] == 'u')
- c++;
- if (s[i] == 'a' || s[i] == 'A')
- c++;
- if (s[i] == 'e' || s[i] == 'E')
- c++;
- if (s[i] == 'y' || s[i] == 'Y')
- c++;
- }
- return c;
- }
- public void FindText(object o)
- {
- string s;
- for (int i = 0; i < path.Count; i++)
- {
- s = path[i] + " " + find(path[i]);
- listBox1.Items.Add(s);
- }
- t1.Abort();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (t1 == null)
- {
- ParameterizedThreadStart p1 = new ParameterizedThreadStart(FindText);
- t1 = new Thread(p1);
- t1.IsBackground = true;
- t1.Start();
- listBox1.Items.Clear();
- }
- }
- catch { }
- }
- }
- }
Add Comment
Please, Sign In to add comment