System.IO.PathTooLongException

  • Thread starter Thread starter George Shubin
  • Start date Start date
G

George Shubin

A routine I have that grabs all file names (fully qualified) from a
directory tree is getting the above error. The error message says: "The
path is too long after being fully qualified. Make sure path is less than
260 characters."

This is clearly a system limitation built into the framework. Has anyone
been able to overcome this limitation? Has anyone a work-around for this?

Thanks.

GS
 
A routine I have that grabs all file names (fully qualified) from a
directory tree is getting the above error. The error message says: "The
path is too long after being fully qualified. Make sure path is less than
260 characters."

This is clearly a system limitation built into the framework. Has anyone
been able to overcome this limitation? Has anyone a work-around for this?

Thanks.

GS

#define MAX_PATH 260

WinDef.h. Windows limits path lengths to 260 characters.
 
From MSDN

Note The C Runtime supports path lengths up to 32768 characters in length,
but it is up to the operating system, specifically the file system, to
support these longer paths. The sum of the fields should not exceed
_MAX_PATH for full backwards compatibility with Windows 98 FAT32 file
systems. Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP
Professional, Windows Server 2003, and Windows Server 2003 NTFS file system
supports paths up to 32768 characters in length, but only when using the
Unicode APIs. When using long path names, prefix the path with the
characters \\?\ and use the Unicode versions of the C Runtime functions.

Cor
 
From MSDN

Note The C Runtime supports path lengths up to 32768 characters in length,
but it is up to the operating system, specifically the file system, to
support these longer paths. The sum of the fields should not exceed
_MAX_PATH for full backwards compatibility with Windows 98 FAT32 file
systems. Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP
Professional, Windows Server 2003, and Windows Server 2003 NTFS file system
supports paths up to 32768 characters in length, but only when using the
Unicode APIs. When using long path names, prefix the path with the
characters \\?\ and use the Unicode versions of the C Runtime functions.

Cor

hmmm, i've always just used max_path :) My guess is the that the
framework is actually using the unicode api calls underneath anyway
(at least on NT based systems). So, maybe just prefixing the paths
with "\\?\" would do the trick?
 
Back
Top