user1594047
user1594047

Reputation: 181

GetDirectories not returning "." and ".."

I wish to list the subdirectories of a given directory so I am using Directory.GetDirectories(string). Everything works fine but I don't see "." and ".." in the return array. Those two shouldn't be there?

Upvotes: 0

Views: 195

Answers (2)

I4V
I4V

Reputation: 35353

Suppose you call as Directory.GetDirectories(path); then

. is the path and

.. is the new DirectoryInfo(path).Parent.FullName

Upvotes: 2

Steve Wellens
Steve Wellens

Reputation: 20620

GetDirectories only returns sub-directories. Not the parent directory, not the current directory.

Documentation:

Return Value
Type: System.String[]
An array of the full names (including paths) of subdirectories in the specified path.

Upvotes: 2

Related Questions