Example #1
0
        public static string EncodeMessageByFileInput(Morse morse, string pathToFile = null)
        {
            string encodedText = null;

            Console.Write("Pfad zur Datei die kodiert werden soll: ");
            if (pathToFile == null)
            {
                pathToFile = Console.ReadLine();
            }
            try
            {
                Console.WriteLine("Kodierter Text: ");
                using (FileStream fs = File.Open(pathToFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (BufferedStream bs = new BufferedStream(fs))
                        using (StreamReader sr = new StreamReader(bs))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                Console.WriteLine("neue Junk");
                                encodedText = morse.EncodeMessage(line);
                                Console.WriteLine(encodedText);
                            }
                            Console.WriteLine();
                        }
            }
            catch (IOException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Die angegebene Datei wurde nicht gefunden");
                Console.ForegroundColor = ConsoleColor.White;
            }
            return(encodedText);
        }
Example #2
0
        private static void EncodeMessageByUserInput(Morse morse)
        {
            Console.Write("Zu kodierender Text: ");
            string textToEncode = Console.ReadLine();

            Console.Write("Kodierter Text: " + morse.EncodeMessage(textToEncode));
            Console.WriteLine();
        }