private void DownloadFile(string input, string[] data)
 {
     try
     {
         if (data.Length == 2)
         {
             var remoteAddress = data[1];
             var fileName      = Path.GetFileName(remoteAddress);
             var myWebClient   = new WebClient();
             myWebClient.DownloadFile(remoteAddress, fileName);
             var path = AppDomain.CurrentDomain.BaseDirectory;
             OutputWriter.WriteMessageOnNewLine($"The file was downloaded here: {path}");
         }
         else
         {
             throw new InvalidCommandException(input);
         }
     }
     catch (WebException)
     {
         //OutputWriter.DisplayException(ExceptionMessages.ForbiddenSymbolsInUrl);
     }
 }
        public void TraverseDirectory(int depth)
        {
            OutputWriter.WriteEmptyLine();
            int            initialIndentation = SessionData.currentPath.Split('\\').Length;
            Queue <string> subFolders         = new Queue <string>();

            subFolders.Enqueue(SessionData.currentPath);
            while (subFolders.Count != 0)
            {
                string currentPath = subFolders.Dequeue();
                int    indentation = currentPath.Split('\\').Length - initialIndentation;
                if (depth - indentation < 0)
                {
                    break;
                }
                OutputWriter.WriteMessageOnNewLine(string.Format("{0}{1}", new string('-', indentation), currentPath));
                try
                {
                    foreach (var file in Directory.GetFiles(currentPath))
                    {
                        int    indexOfSlash = file.LastIndexOf('\\');
                        string fileName     = file.Substring(indexOfSlash);
                        OutputWriter.WriteMessageOnNewLine(new string('-', indexOfSlash) + fileName);
                    }

                    foreach (string directoryPath in Directory.GetDirectories(currentPath))
                    {
                        subFolders.Enqueue(directoryPath);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    OutputWriter.DisplayException(ExceptionMessages.UnauthorizedAccessException);
                }
            }
        }
Exemple #3
0
 public static void PrintStudent(KeyValuePair <string, double> student)
 {
     OutputWriter.WriteMessageOnNewLine($"{student.Key} - {student.Value}");
 }
 private void DisplayInvalidCommandMessage(string input)
 {
     OutputWriter.WriteMessageOnNewLine($"The command {input} is invalid!");
 }
 public static void PrintStudent(KeyValuePair <string, List <int> > student)
 {
     OutputWriter.WriteMessageOnNewLine($"{student.Key} - {string.Join(", ", student.Value)}");
 }
Exemple #6
0
 public static void PrintStudent(KeyValuePair <string, double> student)
 {
     OutputWriter.WriteMessageOnNewLine(string.Format($"{student.Key} - {string.Join(",", student.Value)}"));
 }
Exemple #7
0
 public static void DisplayStudent(KeyValuePair <string, double> student)
 {
     OutputWriter.WriteMessageOnNewLine(string.Format($"{student.Key} - {student.Value}"));
 }