延伸长度路径安全使用吗? [英] Are Extended-Length Paths safe to use?

查看:79
本文介绍了延伸长度路径安全使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶然发现了本文在MSDN上说路径可以是259个字符+ NUL终止,但是如果给它加上"\\?\"前缀,则WinAPI允许您使用

I just stumbled on this article on MSDN that says a path can be 259 characters + NUL termination, but if you prefix it with "\\?\" WinAPI allows you to use the

最大总路径长度为32,767个字符.

maximum total path length of 32,767 characters.

渴望看到它能正常工作,我尝试使用Explorer中的前缀(在XP SP3上),但是它根本不起作用(在任何路径上).如果将\\?\C:\Path\to\an\existing.file放在资源管理器栏上,则会出现找不到文件"错误.

Eager to see it working I tried using that prefix from Explorer (On XP SP3) but it doesn't work at all (on any path). If you put \\?\C:\Path\to\an\existing.file on explorer's bar, it will give the "file not found" error.

所以我很困惑.我可以为(非古代)Windows编写一些代码,以充分利用NTFS上提到的路径大小吗?为什么资源管理器不使用它?

So I'm confused. Can I code something for (non-ancient) Windows that makes full use of the mentioned path size on NTFS? Why Explorer doesn't use it?

推荐答案

有一组API调用可与扩展路径一起使用,而有些则不能. MSDN通常会提到这一点.

There is a SET of API calls that are work with extened-paths and some that do not. The MSDN usually mentions this.

如果您只是在Windows资源管理器中的xp上键入该路径,那是行不通的,因为扩展的路径语法只是WIn32 API的转义序列,而不是Windows资源管理器的转义序列.现在,在Win7中它确实可以工作,因为许多人都希望它可以工作.

Not that if you just type that path into windows explorerunder xp this does not work, because the extened path syntax is just an escape sequence for the WIn32 API and not for windows explorer. Now, In Win7 this does work because many people expected this to work.

对于长路径,如果您更改工作目录或打开以子目录为根的资源管理器,也确实有帮助.

Also for long paths, it does help if you change the working directory or open up explorer with a sub-directory as a root.

这篇关于延伸长度路径安全使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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