开发者

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

开发者 https://www.devze.com 2023-02-03 17:20 出处:网络
This question already has 开发者_运维知识库answers here: Closed 12 years ago. Possible Duplicate:
This question already has 开发者_运维知识库answers here: Closed 12 years ago.

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?


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


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".


Well, first, this has nothing to do with C# in particular, and everything to do with the Windows API, wherein that limit resides. :)

Take a look at this question and its answers, which will lead you to MSDN: Naming Files, Paths, and Namespaces

Unicode file paths (described in the answers to the question, and the MSDN article) may be as solution, with some caveats.

0

精彩评论

暂无评论...
验证码 换一张
取 消