Windows path with no slash after drive letter and colon - what does it point to?

后端 未结 4 1377
悲&欢浪女
悲&欢浪女 2021-02-08 20:34

I have mistyped a path and instead of c:\\foo.txt wrote c:foo.txt. I expected it to either fail or to resolve to c:\\foo.txt, but instead

4条回答
  •  粉色の甜心
    2021-02-08 20:59

    This is standard DOS/Windows behavior and has always been like this. Open a command line and see:

    C:\Users\Tim>d:              # change current drive to d:
    D:\>c:                       # change back to c: - back in the same directory
    C:\Users\Tim>cd d:\users     # change current directory ON D:
    C:\Users\Tim>cd \            # still same directory - backslash leads to top dir
    C:\>d:                       # change current drive to d:
    D:\Users>                    # notice that we're now in the directory D:\Users
    

    The drive letter always references the current directory of that drive; the (leading) backslash gets you to the top directory.

提交回复
热议问题