C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C# programs » C# Directory class programs

C# program to get complete path of current directory

In this program, we will learn how to get complete path of current directory using C# code? To get path of current directory, we have to use static method GetCurrentDirectory() of Directory class.
Submitted by IncludeHelp, on November 12, 2017


This is a method of 'Directory' class, it returns the path of a directory.


string Directory.GetCurrentDirectory();

Return value:

Complete path of current directory.


using System;
using System.IO;

namespace ConsoleApplication1
    class Program
        static void Main()
            string curDir = "";

            curDir = Directory.GetCurrentDirectory();

            Console.WriteLine("Current Directory is :\n"+curDir);


C:\Users\Manju\Documents\Visual Studio 2010\Projects\ihelp\ConsoleApplication1\

Note: In above program, we need to remember, when we use "Directory" class, System.IO namespace must be included in the program.

You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions