How do I resolve a canonical filename in Windows?

前端 未结 8 1369
自闭症患者
自闭症患者 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:51

    I guess I'm a little late, but you can use System.IO.Path.GetFullPath("C:\stuff\things\etc\misc\other..\whatever.txt") and it will return "C:\stuff\things\etc\misc\whatever.txt"

    0 讨论(0)
  • 2020-12-29 13:53

    Roger is correct, there is no simple way. If the volume supports file a unique file index, you can open the file and call GetFileInformationByHandle, but this will not work on all volumes.

    The Windows API call GetFullPathName may be the best simple approach.

    0 讨论(0)
提交回复
热议问题