Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Any way to get around the 260 character limit of a fully qualified path? [duplicate]

Possible Duplicate:
Why does the 260 character path length limit exist in Windows?

I'm trying to figure out a way to get around this dreaded 260 character fully qualified path limit and at the same time I wonder why the hell is there a path limit to begin with!? I know to some people 260 seems to be "a lot", but it truly isn't since I ran into this issue.

Basically:
Why must there be a character limit?
How does one get around it?

like image 904
michael Avatar asked Jan 12 '11 18:01

michael


2 Answers

Use the \\?\ UNC prefix to break out of "DOS mode" for paths. The max length for UNC paths is 32k characters.

More info here: http://msdn.microsoft.com/en-us/library/aa365247.aspx

like image 56
dthorpe Avatar answered Sep 30 '22 01:09

dthorpe


From the MSDN:

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

like image 36
Matten Avatar answered Sep 30 '22 00:09

Matten