Michael said:
I've seen the underlying Windows FindFirstFile and FindNextFile APIs
also report the short names. I suspect the framework is simply using
those APIs.
Well, to be clear: the .NET API doesn't report the short filename. It's
just that a search may match a file based on the short filename (it will
still return the long filename).
And yes, the behavior is certainly because it's inherited from the
unmanaged API for which the .NET API is just a wrapper. But a) that
doesn't mean the original unmanaged API has the appropriate design (*),
and b) it doesn't mean that .NET should have just inherited the behavior.
Pete
(*) The unmanaged API evolved over a period of time when applications
actually may have had more reason to know both the short and long
filenames, and when there were plenty of applications that couldn't
handle anything but short filenames; backward compatibility being so
important in Microsoft's view, there's probably a good argument for the
unmanaged API being the way it is. But even there, we are well past the
point when a variant could have been added to the unmanaged API that
didn't have that funny behavior, and for sure there's no reason a
completely new API (i.e. .NET) needs it.