Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- int main(int argc, char **argv)
- {
- int dirnum = 0;
- int filenum = 0;
- WIN32_FIND_DATA data;
- HANDLE hFind = FindFirstFile("C:\\Users\\Filip\\Desktop\\root\\*", &data); // DIRECTORY
- if (hFind == INVALID_HANDLE_VALUE)
- {
- fprintf(stderr, "FindFirstFile failed on path = \"%s\"\n", data.cFileName);
- abort();
- }
- else {
- do {
- if ((strncmp(".", data.cFileName, 1) != 0) && (strncmp("..", data.cFileName, 2) != 0))
- {
- if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- dirnum++;
- }
- else
- {
- filenum++;
- }
- }
- } while (FindNextFile(hFind, &data));
- FindClose(hFind);
- }
- printf("Num of dirs: %d\n", dirnum);
- printf("Num of files: %d\n", filenum);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement