Windows支持的文件名和共享名的最大长度是多少? [英] What is the maximum length supported in windows for a filename and a sharename?

查看:532
本文介绍了Windows支持的文件名和共享名的最大长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上有一个一般性问题. Windows在文件名和共享名中支持的最大长度是多少?

I have a general question on Windows. What is the maximum length supported in windows for a filename and a sharename?

我知道总路径不应超过255个字符.

I know that the total path should not exceed 255 characters.

当我共享一个具有130个字符的名称的文件夹时,共享名称只有77个字符.为什么?这是Windows中的限制吗?

When I share a folder with name having 130 characters, the share name is only coming to 77 characters. Why? Is this a restriction in Windows?

如果这不是正确的论坛,请引导我进入正确的论坛.我找不到更好的搭配.

Please route me to the correct forum if this is not the right one. I couldn't find any better match.

感谢和问候,

克里希纳

推荐答案

克里希纳,

我认为该主题具有您正在寻找的答案: 命名文件,路径和命名空间.

I think this topic has the answers you're looking for: Naming Files, Paths, and Namespaces.

最大路径长度限制

在Windows API(以下段落中讨论的某些例外情况)中,路径的最大长度为MAX_PATH,它定义为260个字符.本地路径按以下顺序构造:驱动器号,冒号,反斜杠,名称组件 用反斜杠和终止的空字符分隔.例如,驱动器D上的最大路径是"D:\:一些256个字符的路径字符串"< NUL>.其中< NUL>"是指表示当前系统代码页的不可见的终止空字符. (此处使用<>字符是为了视觉清晰,不能成为有效路径字符串的一部分.)

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\<some 256-character path string><NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

注意,Windows API中的文件I/O函数将"/"转换为"/".改为"\"作为将名称转换为NT样式名称的一部分,除非使用"\\?\"前缀,如以下各节所述.

Note  File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections.

Windows API具有许多功能,它们也具有Unicode版本,以允许使用扩展长度的路径,最大总路径长度为32,767个字符.这种类型的路径由用反斜杠分隔的部分组成,每个反斜杠最多包含返回的值 lpMaximumComponentLength 参数中 GetVolumeInformation 函数(此值通常为255个字符).要指定扩展长度的路径,请使用"\\?\"字首.例如,"\\?\ D:\<非常长的路径>". (字符<> 此处用于视觉清晰,不能作为有效路径字符串的一部分.)

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>". (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

注意  最大路径为32,767个字符,因为"\\?\"系统可能会在运行时将前缀扩展为更长的字符串,并且这种扩展适用于总长度.

Note  The maximum path of 32,767 characters is approximate, because the "\\?\" prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.

希望有帮助!

Jim


这篇关于Windows支持的文件名和共享名的最大长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆