-
directory/file
I want to create a program that finds a folder, opens it, and goes through each file in that folder. I'm not sure how to go about this, and i was wondering if anyone could point me in the right direction. I looked at the faq on this site, but none of the code worked (dir.h or dirent.h couldn't be found). I need it to be for a console application. I know how to open individual files, but not a folder, and each file in the folder.
Thanks.
-
I'm guessing this is on Windows OS if dirent.h was not found, and I think you did not finish reading the FAQ entry.
-
"I'm guessing this is on Windows OS if dirent.h was not found, and I think you did not finish reading the FAQ entry."
Are you referring to the Win32 example? I thought this was a Windows Program (not console). I got a bunch of errors when i compiled it.
Code:
error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char [4]' to 'LPCWSTR'
error C2664: 'GetCurrentDirectoryW' : cannot convert parameter 2 from 'char [260]' to 'LPWSTR'
error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'char [260]' to 'LPCWSTR'
error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'const char [3]' to 'LPCWSTR'
error C2664: 'strcmp' : cannot convert parameter 1 from 'const WCHAR [260]' to 'const char *'
error C2664: 'strcmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'
error C2664: 'strcmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'
By the way, is there something i'm doing wrong. Because, everytime i copy and paste some code from Windows Programming tutorials (including this site), i always get these types of errors about converting parameter to LPCWSTR.
Thanks.
-
Cool, you found the Windows one. Where you mentioned dirent.h I thought maybe you didn't scroll down far enough.
The reason for your compilation errors are also part of another FAQ.
-
Ahh, that fixed it.
Thanks.