NTFS:
最长路径为 32,767 个 Unicode 字符,每个目录(或文件)的最大长度为 255 字符。
我刚才试了一下,在 E:data 目录建了一个长度为 239 的成功了。
E:data>md 123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789
长度为 240 的失败了
E:data>md 123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890
文件名或扩展名太长。
当我进入子目录(239长度的那个),再新建一个长度为 1 的,失败。
E:data>cd 123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789
E:data123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
3456789>md 1
文件名或扩展名太长。
至此,晕了。
看看 NTFS 的百科:http://en.wikipedia.org/wiki/NTFS#Internals
File names are limited to 255 UTF-16 code points. Certain names are reserved in the volume root directory and cannot be used for files. These are $MFT, $MFTMirr, $LogFile, $Volume, $AttrDef, . (dot), $Bitmap, $Boot, $BadClus, $Secure, $Upcase, and $Extend.[3](dot) and $Extend are both directories; the others are files. The NT kernel limits full paths to 32,767 UTF-16 code points. There are some additional restrictions on code points and file names.
这里面有一句:There are some additional restrictions on code points and file names,我们跟随链接 "Naming Files, Paths, and Namespaces"
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.
Windows API 里面定义了一个常量 MAX_PATH,这个常量的值是 260,不过常量值不一定是具体的长度,继续向下看,文档里面有一个例子
For example, the maximum path on drive D is "D:some 256-character path string"
好吧,那就试试
E:>md 1234567890123456789012345678901234567890123456789012345678901234567890123
45678901234567890123456789012345678901234567890123456789012345678901234567890123
45678901234567890123456789012345678901234567890123456789012345678901234567890123
4567890123456789012345
文件名或扩展名太长。
删除一个字符,再试,删除,再试,…… 最后终于可以了,目录长度 244,啊,你是 MSDN 请来的逗比吗?
不能着急,继续往下看
When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name (that is, the directory name cannot exceed MAX_PATH minus 12).
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。