Once again, I'm struggling to understand an undocumented behavior of the method GetFiles
in System.IO.Directory
(this is going to make me crazy). While running some routine tests, I found out to my surprise that a call to this method was throwing an exception of type NotSupportedException
, which is not mentioned in the MSDN page about GetFiles
, in the list where the other exceptions are.
For example, this call in C#:
Directory.GetFiles(@"XY:");
throws a NotSupportedException
. My first impression was that the documentation page is missing a piece of information, but after thinking again, I'm not really sure. I mean I've always been assuming that all exceptions I need to care about when using the .NET Framework classes are well-known and documented.
For example, I never put a handler for a FileNotFoundException
when I'm joining strings because I don't expect this exception to occur there.
Is my assumption wrong? Should I expect at least certain exceptions to potentially pop out of anywhere like an OutOfMemoryException
? Any statement I need to read?