Guest User

Untitled

a guest
Nov 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Threading;
  11. namespace WindowsFormsApplication2
  12. {
  13. public partial class Form1 : Form
  14. {
  15. Thread t1 = null;
  16. List<string> path;
  17. List<long> sizeFile;
  18. long SizeAllFile;
  19. DirectoryInfo source;
  20. public Form1()
  21. {
  22. InitializeComponent();
  23. // st = new Stopwatch();
  24. path = new List<string>();
  25. sizeFile = new List<long>();
  26. SizeAllFile = 0;
  27. load();
  28. }
  29. public void load()
  30. {
  31. source = new DirectoryInfo(@"E:\Text");
  32. FileInfo[] files = source.GetFiles();
  33. foreach (FileInfo f in files)
  34. {
  35. path.Add(source.FullName +"\\"+ f.Name);
  36. sizeFile.Add(f.Length);
  37. SizeAllFile += f.Length;
  38. }
  39. }
  40.  
  41. public int find(string path)
  42. {
  43. int c = 0;
  44. StreamReader streamReader = new StreamReader(path);
  45. String s= streamReader.ReadToEnd();
  46. streamReader.Close();
  47. for (int i = 0; i < s.Length; i++)
  48. {
  49. if (s[i] == &#039;o&#039; || s[i] == &#039;O&#039;)
  50. c++;
  51. if (s[i] == &#039;i&#039; || s[i] == &#039;I&#039;)
  52. c++;
  53. if (s[i] == &#039;U&#039; || s[i] == &#039;u&#039;)
  54. c++;
  55. if (s[i] == &#039;a&#039; || s[i] == &#039;A&#039;)
  56. c++;
  57. if (s[i] == &#039;e&#039; || s[i] == &#039;E&#039;)
  58. c++;
  59. if (s[i] == &#039;y&#039; || s[i] == &#039;Y&#039;)
  60. c++;
  61. }
  62. return c;
  63. }
  64.  
  65. public void FindText(object o)
  66. {
  67. string s;
  68. for (int i = 0; i < path.Count; i++)
  69. {
  70. s = path[i] + " " + find(path[i]);
  71. listBox1.Items.Add(s);
  72. }
  73. t1.Abort();
  74. }
  75.  
  76. private void button1_Click(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. if (t1 == null)
  81. {
  82. ParameterizedThreadStart p1 = new ParameterizedThreadStart(FindText);
  83. t1 = new Thread(p1);
  84. t1.IsBackground = true;
  85. t1.Start();
  86. listBox1.Items.Clear();
  87. }
  88. }
  89. catch { }
  90. }
  91. }
  92. }
Add Comment
Please, Sign In to add comment