How do I get current working directory?

Category: System, viewed: 529 time(s).

If you want to get the current directory of your running program you can use the Environment.CurrentDirectory. This will give you the fully qualified path to the current working directory. You might need to as the path to read you configuration file or log files for instance.

using System;

namespace Kodecsharp.Example.System
{
    class CurrentDirectory
    {
        public static void Main(string[] args)
        {
            //
            // Get the fully qualified path of the current working 
            // directory
            //
            string currentDir = Environment.CurrentDirectory;
            Console.WriteLine("Current Directory: " + currentDir);

            Console.ReadLine();
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Statistics

Locations of visitors to this page