public void GetCountVowelsWords(string _path) { string[] words = FileController.Read_File(_path).Split(_spearator, StringSplitOptions.RemoveEmptyEntries); ConsoleColorOutput.Output_Yellow("__Words from file : __"); foreach (string _word in words) { int _tempCountSimbols = 0; ConsoleColorOutput.Output_Usual(_word); foreach (char _simbol in _word) { if (Array.Find(_vowelsWords, s => s == _simbol) != default(char)) { _tempCountSimbols++; } } if (_tempCountSimbols == _word.Length) { _numberVowelsWords++; } } ConsoleColorOutput.Output_Yellow("__Count Vowels words : __"); ConsoleColorOutput.Output_Green(_numberVowelsWords); }
static void Main(string[] args) { Validator.Pattern = @"^([a-zA-Z]:)(\\[^<>\/\\?*\" + "\"" + @"|]*)*\.txt$"; ConsoleColorOutput.Output_Green("Hi dear User :)"); ConsoleColorOutput.Output_Green( "Do you have some text file to read, or you want to create it ?" + "\nEnter Y - if you already have text file" + "\nEnter N - if want to create text file" ); string _userResult = Console.ReadLine(); switch (_userResult.ToLower()) { case "y": { Validator.Validate(); } break; case "n": { FileController.Create_File(); Validator.Validate(); } break; } Console.ReadLine(); }
public static void Validate() { ConsoleColorOutput.Output_Yellow("Please enter full path to your text file."); FilePath = Console.ReadLine(); Check(); }
private static void Check() { WordController _wordController = new WordController(); Match m = Regex.Match(FilePath, Pattern, RegexOptions.Compiled); if (m.Success && File.Exists(FilePath)) { ConsoleColorOutput.Output_Green("Path validation succes :)"); _wordController.GetCountVowelsWords(FilePath); return; } else { ConsoleColorOutput.Output_Red("Validation Error :(\nCheck your path and try again"); Validate(); } }
public static void Create_File() { ConsoleColorOutput.Output_Yellow("Enter directory name"); DirectoryName = Console.ReadLine(); Directory.CreateDirectory($@"C:\{DirectoryName}"); ConsoleColorOutput.Output_Yellow("Enter file name"); FileName = Console.ReadLine(); FileFullPath = $@"C:\{DirectoryName}\{FileName}.txt"; using (FileStream fs = File.Create(FileFullPath)) { byte[] info = new UTF8Encoding(true).GetBytes($"This file is created dynamically."); fs.Write(info, 0, info.Length); } ConsoleColorOutput.Output_Green($"File created with path : {FileFullPath}"); }