Open alkampfergit opened 1 year ago
Actually the problem is a really too long filename, i'd like to have simply a better error message telling that the filename is simply too long.
What LongPath does is to sneak UNC into the mix to support up to 32k characters per path to avoid the PathTooLongException
. UNC still has limitations on each component (filename, directory name, etc.). Depending on the volume, the component limit is 255. The filename in your example is 256 characters. When a UNC component is longer that 255 Windows responds with an error 123 (ERROR_INVALID_NAME
). When LongPath encounters that error, it translates it to ArgumentException
. The same error in .NET would cause an IOException
with the same message and HResult. The fix would be to correct that use of ArgumentException
to be compatible with .NET
I've opened the bug because we found this error on a log with a filename full of weird characters, and we were absolutely sure that one of the char was the issue, then we find that is a simple filename too long. :).
I've opened the bug because we found this error on a log with a filename full of weird characters, and we were absolutely sure that one of the char was the issue, then we find that is a simple filename too long. :).
Amusingly, a file name can only be up to 255 characters in a UNC filename. If you don't use UNC, you can get a 260 character file name in the root of the drive :)
Windows FileSystems are always amazing :D.
If I'm trying to save a file with a really strange name I got that error
I can replicate the bug changing each letter to an X,
"xxxxxx x xxx xxxxx xxxxxxxxxxx xxxxx xxx xxxxxxxx xxxxxxxxx xxxxx xx xxxxxxxxxxx xxxxx . xxxxx xxxxxxx xx xxxx xxxxxxx xxxxx xxxxx, xx xxxxxxxxxx xxxx xxxxxxr xxxxxx xxxx xx xxxxxxx 2 xxxxxxxxs xxx xxxx xxxxx xxxxxxxxxx xxx xxx xxxx xxxxxxxxxxxx xxxxx..eml"
Just create a console app with this code and you got a crash.