C# Environment CurrentDirectory

Description

Environment CurrentDirectory gets or sets the fully qualified path of the current working directory.

Syntax

Environment.CurrentDirectory has the following syntax.


public static string CurrentDirectory { get; set; }

Example

The following example demonstrates setting the CurrentDirectory property.


using System.IO;//from ww w  . j a  v a 2s.c om
using System;
public class MainClass{
  public static void Main(String[] argv){  
    // Change the directory to %WINDIR%              
    Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");    
    DirectoryInfo info = new DirectoryInfo(".");
    Console.WriteLine("Directory Info:   "+info.FullName);

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version