You are on page 1of 1

using System;

using System.IO;
using System.Text;

namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\seren\OneDrive\Рабочий стол\file.txt";
string final = @"C:\Users\seren\OneDrive\Рабочий стол\file2.txt";
using (StreamReader sr = new StreamReader(path, Encoding.Default))
{
string line;
while ((line = sr.ReadLine()) != null)
{
string[] words = line.Split(new char[] { ' ', '.', ',' },
StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < words.Length; i++)
{
var lines = words[i];
if (lines.Length > 2 && lines.Length < 6)
words[i] = "";
//words[i] = lines.Remove(0,lines.Length);
}
string whole = String.Join(" ", words);
File.WriteAllText(final, whole);
}
}
}
}
}

You might also like