如何在Windows中解析规范的文件名? [英] How do I resolve a canonical filename in Windows?

查看:114
本文介绍了如何在Windows中解析规范的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个在Windows中可解析为文件路径的字符串,是否有一种可接受的方法来获取文件名的规范形式?

If I have a string that resolves to a file path in Windows, is there an accepted way to get a canonical form of the file name?

例如,我想知道是否

C:\stuff\things\etc\misc\whatever.txt

C:\stuff\things\etc\misc\other\..\whatever.txt

实际上是否指向同一文件,并将路径的规范形式存储在我的应用程序中.

actually point to the same file or not, and store the canonical form of the path in my application.

请注意,简单的字符串比较将不起作用,任何RegEx魔术也将无效.请记住,自Windows 2000和Windows 2000中的新库结构以来,我们有类似 NTFS重新解析点之类的东西要处理. Windows 7.

Note that simple string comparisons won't work, nor will any RegEx magic. Remember that we have things like NTFS reparse points to deal with since Windows 2000 and the new Libraries structure in Windows 7.

推荐答案

简短答案:并非如此.

在Windows上,没有简单的方法来获取文件的规范名称.本地文件可以通过重新解析点,通过SUBST获得.您要处理NTFS联结吗? Windows快捷方式? \\?\转义的文件名

There is no simple way to get the canonical name of a file on Windows. Local files can be available via reparse points, via SUBST. Do you want to deal with NTFS junctions? Windows shortcuts? What about \\?\-escaped filenames

可以通过映射的驱动器号或UNC获得远程文件.是原始服务器的UNC吗?您在使用DFS吗?服务器是否使用重新解析点等?服务器是否有多个名称可用? IP地址呢?它有多个IP地址吗?

Remote files can be available via mapped drive letter or via UNC. Is that the UNC to the origin server? Are you using DFS? Is the server using reparse points, etc.? Is the server available by more than one name? What about the IP address? Does it have more than one IP address?

因此,如果您要查找Windows上的inode编号之类的内容,就不会找到它.参见例如此页面

So, if you're looking for something like the inode number on Windows, it ain't there. See, for example, this page.

这篇关于如何在Windows中解析规范的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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