DirectoryInfo.Create
is throwing DirectoryNotFoundException
when the path is longer than 260 characters. I understand that it is not possible to create the directory, but the method also supports PathTooLongException
. Why isn't it thrown instead? When the path's lenght is >248 and <260 a PathTooLongException
is thrown. Shouldn't both cases throw the same exception?
My code:
DirectoryInfo fullArchiveDirectoryInfo = new DirectoryInfo(fullArchiveDirectory);
fullArchiveDirectoryInfo.Create();
My project targets .NET Framework 4.6.2.
(Update 1)
For example:
- C:(...)-9223372036854775808\86dcadfc1e0746649408 - 264 characters -
DirectoryNotFoundException
- C:(...)-9223372036854775808\86dcadfc1e074664 - 260 characters -
PathTooLongException
- C:(...)-9223372036854775808\f872 - 248 characters - no exception
Additional note: I tested with LinqPad (v5.31.00) and there I always get a PathTooLongException
with a path 264 characters long.