Get Paths to Windows Special Folders from VB.NET

Special Folders are Windows folders such as: My Documents, Desktop, Favorites, Recent, Documents and Settings, Cookies,.... Here's how to get the path to these folders.

VB.NET code:

   '
   ' Declare a variable of type SpecialFolder.
   '
   Dim typeSpecialFolder As System.Environment.SpecialFolder
   '
   ' Loop through all special folders.
   '
   For Each typeSpecialFolder In _
     typeSpecialFolder.GetValues(GetType(Environment.SpecialFolder))
      Console.WriteLine(System.Environment.GetFolderPath(typeSpecialFolder))
   Next

C# code:

   System.Environment.SpecialFolder typeSpecialFolder;
		
   foreach (System.Environment.SpecialFolder atypeSpecialFolder in 
                     System.Enum.GetValues(typeof(Environment.SpecialFolder)))
   {
      typeSpecialFolder = atypeSpecialFolder;
      Console.WriteLine(System.Environment.GetFolderPath(typeSpecialFolder));
   }

You can also use code similar to:

   Using System.IO;

   DirectoryInfo di = _
     New DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
   Console.WriteLine(di.FullName);

About TheScarms
About TheScarms


Sample code
version info

If you use this code, please mention "www.TheScarms.com"

Email this page


© Copyright 2016 TheScarms
Goto top of page