BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

System Information
.NET 1.1+

Locating the System Folder

Some software needs to interact with files and subfolders in the standard Microsoft Windows system folder. The location of this folder varies according to the user's configuration but can be found easily.

Environment.SystemFolder

Sometimes you will need to work with standard or custom files that are present in the Microsoft Windows system folder. This special folder holds files that are required by the operating system. The location of the folder is determined by the version of Windows being used and the configuration used during the operating system's installation.

It is a simple task to identify the path to the system folder when using the .NET framework. You can use methods that I've described in earlier articles, such as using the Environment class's GetFolderPath method and passing the System constant. However, although this method is more flexible, when you only need the path of the system folder, using the SystemDirectory property can be more readable. This static property returns a string containing the full path to the system folder.

Console.WriteLine(Environment.SystemDirectory); // Outputs "C:\windows\system32"
2 May 2014