Home DotNet Finding Windows folder with C#
Author:

Most of the time developer thinks that the default Windows is from this path: C:\Windows or C:\WINNT but this is not always the case. Some people might have the default Operating System install on D: or E:. So to ensure that you always get the accurate Windows system path use this code in your C# code to read the environement variable.

   private void OnEnabled(object sender, EventArgs e)

        {

            string windir = Environment.GetEnvironmentVariable("windir");

            string sysRoot = Environment.GetEnvironmentVariable("SystemRoot");

 

        }



Comments (0)
Write comment
Your Contact Details:
Comment:
Security
Please input the anti-spam code that you can read in the image.

"