Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- StreamReader sr = new StreamReader(@"C:Readfile.txt");
- text = sr.ReadToEnd();
- string textData = Regex.Replace(text, @"[^0-9a-zA-Z]+", " ");
- char[] whitespace = new char[] { ' ', 't' };
- string[] data = textData.Split(whitespace);
- int i = 1;
- while (i < data.Length)
- {
- st = data[i];
- string[] source = text.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' }, StringSplitOptions.RemoveEmptyEntries);
- var matchQuery = from word in source
- where word.ToLowerInvariant() == st.ToLowerInvariant()
- select word;
- int wordCount = matchQuery.Count();
- k += wordCount + ": " + st + "n";
- //MessageBox.Show(k);
- i++;
- }
- StreamWriter sr4 = new StreamWriter(@"C:WhatFound.txt");
- sr4.Write(k);
- }
- catch (Exception ce)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement