Get System Environment Special Folders and Temp Folder Path

By Peter Bromberg

The System.Environment namespace has an enumeration that provides the location of all special folders. This code snippet enumerates them and also shows the Windows Temp Path.

static void Main(string[] args)
        {
             foreach (Environment.SpecialFolder s in Enum.GetValues(typeof(Environment.SpecialFolder)))
            {
               Console.WriteLine("{0} folder : {1}",
                     s, Environment.GetFolderPath(s));
            }

            // Get the Windows Temp folder path
            String tempFolderPath = Path.GetTempPath();
           Console.WriteLine("Temp Path:" + tempFolderPath);

           Console.ReadLine();
        }

Get System Environment Special Folders and Temp Folder Path  (4429 Views)