I'm trying to find all the files in a directory named "en" and no matter how many times I search through with FindNextFile, it always returns the same thing. "en" which is not a file or directory inside of \en. Anyone see a problem?
From looking at
FindFirstFile
FindNextFile
WIN32_FIND_DATA
it seems you are using the functions properly.
So, that leaves the problem up to the path you are passing into your code as argv[1].
According to the docs, it seems you should be using a path like this :
drive:\\folder\\en*
I have tried this before with single and double backspaces and the result is the same
First file: en
Second file: en
Third file: en
I am aware that the first two things in a folder are references to the folder itself "." and the parent ".." but even if it was picking up these, the second "file" should be "Desktop" and the third should be the first file in the actual folder. However, this is not the case, and I am confused.
I'm trying to find all the files in a directory named "en" and no matter how many times I search through with FindNextFile, it always returns the same thing. "en" which is not a file or directory inside of \en. Anyone see a problem?
I misread what you said earlier. I thought you were looking for all the files starting with 'en', not for all the files in a directory named 'en'. You need to alter your search path to something like this :
drive:\\folder\\en\\*
(Only escape the backslashes if you aren't entering it in manually)
I assume before you were trying to search by using something like this :
drive:\\folder\\en
and that would only find the en folder, which is why it keeps showing up when you call FindNextFile.
Also, make sure you check the return value of FindNextFile. It will return false when there are no more matching files and then calling GetLastError will return ERROR_NO_MORE_FILES.
Since you're asking the user for a directory, you need to append a backslash if there isn't one, and an asterisk as a wildcard to match all files and folders within the directory specified.
That fixed it, thank you.