Home »
.Net »
C# Programs
C# - Environment.CurrentDirectory Property with Example
In this tutorial, we will learn about the C# Environment.CurrentDirectory property with its definition, usage, syntax, and example.
By Nidhi Last updated : March 30, 2023
Environment.CurrentDirectory Property
The Environment.CurrentDirectory property is used to set and get the path of the current directory.
Syntax
string Environment.CurrentDirectory
Parameter(s)
Return Value
This property returns string that contains the full path of the current directory.
C# Example of Environment.CurrentDirectory Property
The source code to get the full path of the current directory using Environment class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
string curDir = Environment.CurrentDirectory;
Console.WriteLine("Full path of current directory:");
Console.WriteLine(curDir);
}
}
Output
Full path of current directory:
C:\Users\Arvind\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug
Press any key to continue . . .
C# Environment Class Programs »