Understanding the error "PathTooLongException - The specified path, file name, or both are too long"
Who is this article for?Users who encounter this error when attaching a file.
When attempting to attach a file, you may encounter the error message PathTooLongException - The specified path, file name, or both are too long.
This article explains what causes the issue and how to resolve it.
1. Issue
When dropping a file attachment in to the application, you may receive this error message:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
The fully qualified path name includes:
- The file name (including extension)
- The folder names
- The drive letter, plus colon
- All backslashes in the path
So for example, the full path below is 39 characters:
C:\Temp\Some Folder\Some File Name.docx
It is made up of:
|
Item |
|
Number of characters |
|
File Name |
"Some File Name.docx" |
19 |
|
Total of folder names |
"Temp", "Some Folder" |
15 |
|
Drive letter and colon |
C: |
2 |
|
Backslashes |
\ \ \ |
3 |
2. Solution
The workaround here is to either rename the file to a shorter name, or copy it to a shorter path.