Partager via


File System Limits

When you create a file or a folder, do you check that the full path is not too long?! Make sure that you handle the PathTooLongException:

 

PathTooLongException

 

Try to exceed the maximim lenght on Windows, and you'll get this error:

 

Destination Path Too Long

 

Here are some limits in Windows APIs that you should know about:

 

#define MAX_PATH 260 // Maximum length of full path
#define MAX_DIR 256 // Maximum length of path component
#define MAX_FNAME 256 // Maximum length of file name component
#define MAX_EXT 256 // Maximum length of extension component

And here are the limits of almost all file systems: https://en.wikipedia.org/wiki/Comparison_of_file_systems#limits

For more details and workarounds, please read: https://blogs.msdn.com/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx