Skip to content
Related Articles
Open in App
Not now

Related Articles

C# Program to Get the Path of System Directory Using Environment Class

Improve Article
Save Article
  • Last Updated : 03 Nov, 2021
Improve Article
Save Article

In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. In this article, we will discuss how to get the path of the system directory. So we use the SystemDirectory property of the Environment Class. This property returns the full path of the directory of the system



Return Type: The return type of this property is a string and this string represents the path of the system directory.



// C# program to find the path of system directory
using System;
class GFG{
static public void Main()
    // Declaring a variable
    string resultDir = "";
    // Now finding the path of system directory
    // Using the SystemDirectory property of
    // the Environment class
    resultDir = Environment.SystemDirectory;
    // Displaying the result
    Console.WriteLine("System Directory:" + resultDir);


System Directory:
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!