Does Directory.GetDirectories (path) return full paths or just names?

The MSDN documentation says that it only returns directory names ("Return value Type: ... An array of type String containing the names of subdirectories in the path."), However in their code example they recurs without their concatenation, does this mean that they return full paths?

i.e. their code example:

 public static void ProcessDirectory(string targetDirectory) { // Process the list of files found in the directory. string [] fileEntries = Directory.GetFiles(targetDirectory); foreach(string fileName in fileEntries) ProcessFile(fileName); 
  // Recurse into subdirectories of this directory. string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory); foreach(string subdirectory in subdirectoryEntries) ProcessDirectory(subdirectory); } 

code>

does not work if the GetDirectories method returns only directory names!

+4
source share
2 answers

As indicated on the MSDN page:

The names returned by this method with the catalog prefix information provided in the path [ed: function parameter].

+8
source

It returns full paths. You can check with PowerShell:

 [IO.Directory]::GetDirectories('C:\') 
+5
source

All Articles