System.IO.PathTooLongException

  • Thread starter Thread starter Donald Xie
  • Start date Start date
D

Donald Xie

Hi,

(This is a repost - I posted this last week, but
misspelled my email alias.)

The documentation states that this "exception is
thrown when a pathname or filename is longer than the
system-defined maximum length". In my case, this max.
length is 260 characters on WinXP. Is there any way to
change this value? If not, are there any workarounds?

Thanks,
Donald Xie
 
Hi Donald,

Thank you for posting to the MSDN newsgroups.

Based on my research and experience, this issue is by design. Please refer
to the following URL:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemiodirectoryinfoclassctortopic.asp
"...
PathTooLongException
...
The specified path, file name, or both exceed the system-defined maximum
length. For example, on Windows-based platforms, paths must be less than
248 characters, and file names must be less than 260 characters.The
specified path, file name, or both are too long. Paths must be less than
248 characters, and file names must be less than 260 characters.
..."

I will try my best to find if there is a work around for this issue. More
time is needed.

Best regards

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jacob,

Thanks for the info. Yes it'd be great if there is a
workaround.

Thanks,
Donald Xie
 
Hi Donald,

As I understand, you are looking for a way to change the "system-defined
maximum length".

I have done a lot of research regarding this issue. Unfortunately, I am
afraid that there is not a work around for this issue. This is a hardcoded
value in both the .NET Framework and the OS. The system APIs depend on
these hardcoded values so we cannot change them. From windef.h in Platform
SDK you could see MAX_PATH is defined as 260.

On the other hand, you can send your feedback/wish of our products to
Microsoft directly.

Contact Microsoft
http://support.microsoft.com/default.aspx?pr=cntactms
"...
Microsoft Wish
Make a product suggestion or feature request. Product enhancement
suggestions can include:
Improvements on existing products
Suggestions for additional features
Ways to make our products easier to use
..."

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jacob,

Thanks for taking time to look into this. Now that you've
confirmed that it's an OS limit, at least I won't waste
time to try to use APIs.

I'll post a suggestion to the wishlist. Meanwhile, back to
change my app...

Thanks again,
Donald Xie
 
Hi Donald,

As I understand, you are looking for a way to change the "system-defined
maximum length".

I have done a lot of research regarding this issue. Unfortunately, I am
afraid that there is not a work around for this issue. This is a hardcoded
value in both the .NET Framework and the OS. The system APIs depend on
these hardcoded values so we cannot change them. From windef.h in Platform
SDK you could see MAX_PATH is defined as 260.

According to the documentation, on the NT family of Windows long paths
can be passed to the Win32 APIs (such as CreateFile or
CreateDirectory). According to the documentation, filenames prefixed
with \\?\ can be used with the Unicode versions of these functions to
allow paths of ~32000 characters.

I don't know anything about the .NET Framework's support for this, but
it is not an OS limitation.

Chris
 
Back
Top