-3

this is my FindFile program

I have one question.

what are "." and ".." directory? what are they doing? why are they searched? I don't have . and .. directory in that folder which I wanted to search. I wonder. tell me please ... here, it's the findfile code.

GetWindowsDirectory(Path,MAX_PATH);
lstrcat(Path,"\\*.*");
hSrch=FindFirstFile(Path,&wfd);
if (hSrch==INVALID_HANDLE_VALUE) return;
while (bResult) {
    if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
        wsprintf(fname,"[ %s ]",wfd.cFileName);
    } else {
        wsprintf(fname,"%s",wfd.cFileName);
    }
    SendMessage(hList,LB_ADDSTRING,0,(LPARAM)fname);
    bResult=FindNextFile(hSrch,&wfd);
}
FindClose(hSrch);
2
  • 5
    when you list paths you have current dir (.) and parent dir (..) unless you're at the root dir. Always filter them out from your directory scan. Sep 10, 2016 at 18:23
  • Thanks for the answer. I'm practicing this to use it for loading some images and sound. should I do like this? if(fname != TEXT(".")) like that? uh.. to sort out "." and ".." Sep 10, 2016 at 18:27

1 Answer 1

1

I don't have . and .. directory in that folder which I wanted to search.

You always have these intrinsic directories at any POSIX compliant file system.

. denotes the current working directory.

.. denotes the parent directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.