0

I'm trying to create an OpenFilePikcker control in WPF and I use the DirectoryInfo.GetDirectories() to get all sub directories in a certain directory however in the case of Drive C:/ I do not want that method return the system directories like Windows and Program Files. How is that possible to do? Any help is appreciated.

user3530012
  • 720
  • 2
  • 20
  • 37

1 Answers1

1

you may need to filter them manually after you retrieve them using GetDirectories() as there is no native method available for such filter

you may use Environment.GetFolderPath to retrieve some of the defined directory including those you look forward to filter out

eg

string sysDir = Environment.GetFolderPath(Environment.SpecialFolder.System);

and remove the directory from your list, and like wise look for all you are not interested in and remove them eg. Windows, ProgramFiles etc.

below is the available special folders which you might choose to refer too

folders

pushpraj
  • 13,458
  • 3
  • 33
  • 50