Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parallel.ForEach(File.ReadLines(path), opt, a => { Fil(a); opt.CancellationToken.ThrowIfCancellationRequested(); });
- using (FileStream fs = File.Open(accpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- using (BufferedStream bs = new BufferedStream(fs))
- {
- using (StreamReader sr = new StreamReader(bs))
- {
- string line;
- while ((line = sr.ReadLine()) != null)
- {
- Fil(line);
- }
- }
- }
- }
- void Fil(string txtresult)
- {
- try
- {
- mres.Wait();
- string reg = @"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*";
- Regex regex = new Regex(reg);
- var dpl = txtresult.Split(' ');
- foreach (var m in dpl)
- {
- MatchCollection matches = regex.Matches(m);
- if (matches.Count > 0)
- {
- foreach (Match match in matches)
- {
- var matchh = Regex.Unescape(match.Value);
- var ss = m.Split('@')[1];
- var ch = ';';
- if (ss.Contains(":"))
- ch = ':';
- string pass = ss.Split(ch)[1];
- if (pass.Length > min && pass.Length < max)
- {
- // acs.Add(matchh + ch + pass);
- lock (lockerGood)
- {
- sw.WriteLine(matchh + ch + pass);
- }
- }
- }
- }
- }
- }
- catch(Exception e)
- {
- lock (lockerErr)
- WriteToLog($"Ошбика в строке {txtresult}, текст ошибки {e.Message}");
- }
- }
- foreach(var line in File.ReadLines(filePath))
- {
- Fil(line);
- }
- Parallel.ForEach(File.ReadLines(path), opt, a => { Fil(a); opt.CancellationToken.ThrowIfCancellationRequested(); });
- 1) Чтение с диска - медленная операция
- 2) Чем меньше чтений диска, тем лучше
- 3) Оперативная память не бесконечная
- using(var bufferedFileStream =
- new BufferedStream(File.OpenRead(path), 1024*1024)) // буфер в мегабайт
- {
- ....
- }
- using(var reader =
- new StreamReader(
- new BufferedStream(File.OpenRead(path), 1024*1024) // буфер в мегабайт
- ))
- {
- ....
- }
Add Comment
Please, Sign In to add comment