Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FileDetails
- {
- class FileDetails
- {
- static void Main(string[] args)
- {
- try
- {
- Console.OutputEncoding = Encoding.UTF8;
- //args = new string[] { "text.txt" };
- Console.WriteLine(args.Length);
- foreach (var arg in args)
- {
- Console.WriteLine(arg);
- }
- var filename = args[0];
- FileStream stream = new FileStream(filename, FileMode.Open);
- StreamReader reader = new StreamReader(stream);
- var streamLength = stream.Length;
- var contents = new char[streamLength];
- for (int i = 0; i < streamLength; i++)
- {
- contents[i] = (char)reader.Read();
- }
- Summarize(contents, out int vowelCount);
- Console.WriteLine(contents);
- Console.WriteLine($"Всего букв - {streamLength}\n" +
- $"Глассные - {vowelCount}\n" +
- $"Согласные - {streamLength - vowelCount}");
- reader.Close();
- stream.Close();
- }catch(Exception ex)
- {
- Console.WriteLine(ex);
- }
- Console.ReadKey();
- }
- static public void Summarize(char[] contents, out int vowelCount)
- {
- vowelCount = 0;
- foreach (var ch in contents)
- {
- if("AEIOUaeiou".IndexOf(ch) != -1)
- {
- vowelCount++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement