I first added 2 unit tests that demonstrate issues when dealing with UNC paths near the MAX_PATH limit, one in Directory.CreateDirectory and one in Directory.EnumerateDirectories.
Empirically, I found that the point at which Windows starts getting upset is MAX_PATHminus the length of the \\hostname\ prefix of the UNC path. I was therefore able to fix both issues by modifying the Path.CheckAddLongPathPrefix method such that it adds the long path prefix if the path exceeds this limit, rather than MAX_PATH.
I first added 2 unit tests that demonstrate issues when dealing with UNC paths near the
MAX_PATH
limit, one inDirectory.CreateDirectory
and one inDirectory.EnumerateDirectories
.Empirically, I found that the point at which Windows starts getting upset is
MAX_PATH
minus the length of the\\hostname\
prefix of the UNC path. I was therefore able to fix both issues by modifying thePath.CheckAddLongPathPrefix
method such that it adds the long path prefix if the path exceeds this limit, rather thanMAX_PATH
.