-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileReader.cs
More file actions
26 lines (25 loc) · 824 Bytes
/
Copy pathFileReader.cs
File metadata and controls
26 lines (25 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace WordCounterApp.Services
{
public class FileReader
{
public void ReadAndProcess(string inputPath, string outputPath)
{
try
{
string text = File.ReadAllText(inputPath);
var words = text.Split(new char[] { ' ', '.', ',', '!', '?', ';', ':', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
.Select(word => word.ToLower()).ToList();
FileWriter writer = new FileWriter();
writer.ProcessAndWrite(outputPath, words);
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка чтения файла: {ex.Message}");
}
}
}
}