Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace Drafty
- {
- class Program
- {
- static void Main(string[] args)
- {
- string filename;
- Console.Write("Введите имя текстового документа на диске D: ");
- filename = Console.ReadLine();
- string path = @$"D:\{filename}.txt";
- if (!File.Exists(path))
- {
- Console.WriteLine("Файл не найден");
- return;
- }
- string content = File.ReadAllText(path);
- string[] elements = content.Split(' ', StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine($"В файле {elements.Length} чисел");
- for (int i=0; i<elements.Length; i++)
- {
- Console.Write(elements[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment