0

The question title is seemingly straight forward and self-explanatory. The issue is that the SpecialFolders enumeration does not include Libraries Folder and I really need to access it and display its folders in a ListBox. Is there any way to do this please?

user3530012
  • 720
  • 2
  • 20
  • 37

1 Answers1

3

The path to the Libraries folder is %APPDATA%\Microsoft\Windows\Libraries, you can use SpecialFolder.ApplicationData, which on Windows is the same as the %APPDATA% environment variable:

var appData = Environment.GetFolderPath(
        Environment.SpecialFolder.ApplicationData);

var librariesFolder = Path.Combine(appData, @"Microsoft\Windows\Libraries");

Another way to get the full path is to just expand the environment variable:

var librariesFolder = Environment.ExpandEnvironmentVariables(
        @"%APPDATA%\Microsoft\Windows\Libraries");

Anyways, this is Windows specific and won't work on other platforms, which is pretty much the single good reason to use Environment.SpecialFolder in the first place.

khellang
  • 17,550
  • 6
  • 64
  • 84