I wrote some codes to create a directory named "E:\hkhkhkhk\...." in c++. It actually created "...." iteratively. And the parent directory "hkhkhkhk" cannot be removed.

I was wondering how the system explains "....".

The code is as below, execute it in virtual machine.

#include <windows.h>
#include <iostream>

using namespace std;

int main()
    if (!CreateDirectoryA("E:\\hkhkhkhk\\....\\", NULL))
        cout << GetLastError() << endl;

    return 0;



1 Answer 1


Windows doesn't allow programs to use paths ending with a dot; whenever a program tries to access such a path, all dots are quietly removed from the end.

You bypassed this restriction when creating the directory since your path actually ends with a backslash, but other programs (e.g. Windows Explorer) don't do this.

So when you double-click the directory in Explorer, it tries to change to E:\hkhkhkhk\.... but actually gets E:\hkhkhkhk\ (which is the same as the parent directory), creating the illusion of infinite recursion when in reality you never go anywhere at all.

  • 1
    Your explanation is very helpful, thx alot!
    – joshqin
    Jun 12, 2019 at 4:58

Not the answer you're looking for? Browse other questions tagged .