Advertisement
Danvil

Проход ФС [C#]

Feb 12th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace Раскрытие_ФС
  9. {
  10.     class Program
  11.     {
  12.         static void showFileSystem(string strPath, int i)
  13.         {
  14.             Console.ForegroundColor = ConsoleColor.White;
  15.             foreach (string f in Directory.GetFiles(strPath))
  16.             {
  17.                 Console.WriteLine((new string(' ', i + 1)) + '+' + Path.GetFileName(f));
  18.             }
  19.             Console.ForegroundColor = ConsoleColor.Green;
  20.             foreach (string s in Directory.GetDirectories(strPath))
  21.             {
  22.                 Console.WriteLine((new string(' ', i)) + '-' + Path.GetFileName(s));
  23.                 Console.ResetColor();
  24.                 showFileSystem(s, i + 1);
  25.             }
  26.         }
  27.         static void Main(string[] args)
  28.         {
  29.             string strPath;
  30.             int i = 1;
  31.             Console.WriteLine("Введите путь к папке:");
  32.             strPath = Console.ReadLine();
  33.             showFileSystem(strPath, i);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement