all groups > visual c > november 2007 >
You're in the

visual c

group:

Directory::GetDirectories returning non-existent directories


Directory::GetDirectories returning non-existent directories Peteroid
11/2/2007 9:21:03 PM
visual c: Assuming you have the default directory settings, try this code:

String^ full_path = "c:\\Users\\Owner\\Documents" ;
array<String^>^ dir_list = Directory::GetDirectories( full_path ) ;

In my case, it returns all the directories as it should in dir_list, but it
also returns the following non-existent (hidden?) directories:

My Music
My Pictures
My Videos

If I try to Directory::GetFiles( ) on any of these directories it throws an
exception, but it will successfully return the files of those directories
which are visible or do exist.

If I do a 'search' for any directories with those names, they are not found.

I have a Windows Vista machine, and I'm programming in VS VC++ 2008 Express
(Beta 2) /cli pure.

What is going on here?
Re: Directory::GetDirectories returning non-existent directories Doug Harrison [MVP]
11/2/2007 11:48:07 PM
On Fri, 2 Nov 2007 21:21:03 -0700, "Peteroid" <peteroid69@hotmail.com>
[quoted text, click to view]

In a nutshell, they're junction points MS added to Vista to help existing
programs that did things the wrong way. This article explains all:

Junction Points and Backup Applications
http://msdn2.microsoft.com/en-us/library/bb756982.aspx
<q>
These junction points have file attributes of FILE_ATTRIBUTE_REPARSE_POINT
& FILE_ATTRIBUTE_SYSTEM and the ACL’s are set to “Everyone Deny Read”.
Applications must have permissions in order to call out and traverse a
specific path. However, enumerating the contents of these junction points
is not possible.
</q>

The article very helpfully lists all the junction points, including the
ones you encountered. Hopefully, there is a Directory::GetDirectories
overload that you can use to prevent it from returning these unwanted
junctions.

To examine the security attributes of these junction points, you'll have to
go to Folder Properties and disable the options that hide files. Then
you'll be able to see them in Documents, as well as several in the root of
your profile folder.

--
Doug Harrison
AddThis Social Bookmark Button