I would like to check how many files are there in the specified directory. For instance I would have a directory next to my .exe called resources and I would like to check how many of .txt files are located in it.
How this can be done in C++ in Windows?
This depends on the operating system. On Windows, you would use
FindFirstFileandFindNextFileto enumerate the directory contents, using an appropriate filter such as"*.txt". Don’t foget to callFindClosewhen you’re done.On Unix-based operating systems, you would use
opendir(3)andreaddir(3)to enumerate the directory contents. You’ll have to filter the file names yourself. Don’t forget to callclosedir(3)when you’re done.