Made it work with on Windows

Folder traversal on Windows was an endless loop, because currentFolder == 'C:\' , it never passed the comparison (currentFolder != "/" && currentFolder != ".")