예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        public static void Validate()
        {
            ConsoleColorOutput.Output_Yellow("Please enter full path to your text file.");

            FilePath = Console.ReadLine();

            Check();
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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}");
        }