How can I obtain the case-sensitive path on Windows?

后端 未结 8 620
慢半拍i
慢半拍i 2020-12-01 18:00

I need to know which is the real path of a given path.

For example:

The real path is: d:\\src\\File.txt
And the user give me: D:\\src\\file.txt
I nee

8条回答
  •  自闭症患者
    2020-12-01 18:23

    On Windows, paths are case-insensitive. So both paths are equally real.

    If you want to get some kind of a path with canonical capitalization (i. e. how Windows thinks it should be capitalized), you can call FindFirstFile() with the path as a mask, then take the full name of the found file. If the path is invalid, then you won't get a canonical name, natually.

提交回复
热议问题