In VC++, how should I check if a directory is empty? Is there any function? I am a novice here.
+2
A:
You could use some methods like FindFirstFile and FindNextFile to check if there are any files in the directory.
Also see this:
If the directory is empty, FindFirstFile() will only find the entry for the directory itself (".") and FindNextFile() will fail with ERROR_FILE_NOT_FOUND.
schnaader
2009-07-16 08:44:47
+1, didn't know that this method exists.
schnaader
2009-07-16 08:54:54
Neither did I, and we both thought of the answer obliquely. The question was how to check whether the folder was empty or not, not how many files it had.
Abbas
2009-07-16 08:58:18