NTFS 文件路径有长度限制吗?
为什么在 NTFS 文件系统中无法创建路径字符数超过 255 个的深层路径? FAT32好像有限制,但NTFS也存在?谁能提供一些文件吗?
非常感谢!
Why can not I create a deep path whose characters in path is more than 255 in NTFS File System?
It seems a limits of FAT32, but also exist in NTFS? Can anyone provide some documents?
Many Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
260 个字符的限制不是文件系统的限制,而是 Win32 API 的限制。 Win32 将 MAX_PATH 定义为 260,API 使用它来检查传递给 FileCreate、FileOpen 等函数(由 .NET 在 BCL 中使用)的路径长度。
但是,您可以绕过 Win32 规则并创建最多 32K 个字符的路径。 基本上您需要使用您可能没有见过的“\\?\C:\MyReallyLongPath\File.txt”语法前。最后我检查了一下,.NET 中的 File 和 FileInfo 类阻止您使用这种类型的路径,但您绝对可以从 C/C++ 中执行此操作。这是获取更多信息的链接。
http://msdn.microsoft.com/en-us/库/aa365247(VS.85).aspx
The 260 character limitation is not a limitation of the file system, but of the Win32 API. Win32 defines MAX_PATH as 260 which is what the API is using to check the length of the path passed into functions like FileCreate, FileOpen, etc. (which are used by .NET in the BCL).
However, you can bypass the Win32 rules and create paths up to 32K characters. Basically you need to use the "\\?\C:\MyReallyLongPath\File.txt" syntax which you may not have seen before. Last I checked, the File and FileInfo classes in .NET prevented you from using this type of path, but you can definitely do it from C/C++. Here's a link for more info.
http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
引自维基百科
http://en.wikipedia.org/wiki/NTFS
Quoted from wikipedia
http://en.wikipedia.org/wiki/NTFS
文档。您当然应该能够创建超过 255 字节的文件路径,只要每个单独的路径组件都位于该路径下。但是,您必须使用文件访问调用的 Unicode (W) 版本才能获得此行为;如果您使用基于 ANSI (A) 字节的接口(例如 stdio 使用的接口),您将受到旧的 Unicode 之前路径接口的限制。
Doc. You should certainly be able to create longer filepaths than 255 bytes, as long as each individual path component is under that. However you must be using the Unicode (W) versions of the file access calls to get this behaviour; if you're using the ANSI (A) byte-based interfaces such as those used by stdio, you'll be stuck with the limitations of the old pre-Unicode path interface.