Advertisement
Guest User

Untitled

a guest
May 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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 zad10._1._6
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Console.WriteLine("Unesite putanju: ");
  15.             string putanja = Console.ReadLine();
  16.  
  17.             while (!Directory.Exists(putanja))
  18.             {
  19.                 Console.WriteLine("Putanja ne postoji. Unesite novu putanju: ");
  20.                 putanja = Console.ReadLine();
  21.             }
  22.  
  23.             Console.WriteLine($"\nOd navedene putanje može se doći do sljedećih direktorija: \n");
  24.  
  25.             Direktoriji(putanja);
  26.         }
  27.  
  28.         static void Direktoriji (string putanja)
  29.         {
  30.             string[] sDirs1 = Directory.GetDirectories(putanja);
  31.             if (sDirs1.Length == 0) return;
  32.  
  33.             foreach (string sDir1 in sDirs1)
  34.             {
  35.                 string DirName = new DirectoryInfo(sDir1).Name;
  36.                 Console.WriteLine($"\nDirektorij {DirName} (putanja: {sDir1})");
  37.                 Direktoriji(sDir1);
  38.             }    
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement