简体   繁体   中英

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?

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.

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

. is the path and

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM