Articles → CSHARP → Get The List Of All Folders On A Given Path Using C#

Get The List Of All Folders On A Given Path Using C#






Path




Picture showing the list of all folders on a given path
Click to Enlarge


Code


using System; 
using System.IO;
 
namespace TestApp {
    class Program {
        static void Main(string[] args) {
            DirectoryInfo di = new DirectoryInfo(@ "complete_path");
            foreach(DirectoryInfo d in di.GetDirectories()) {
                Console.WriteLine(d.Name);
            }
            Console.Read();
        }
    }
}



Output


Picture showing the list of all folders on a given path  fetched programatically using C#
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, June 5, 2017

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250