How do I resolve a canonical filename in Windows?

前端 未结 8 1427
自闭症患者
自闭症患者 2020-12-29 13:18

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?

For example, I\'d like to know whether

8条回答
  •  没有蜡笔的小新
    2020-12-29 13:33

    Short answer: not really.

    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

    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?

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

提交回复
热议问题