C++ Showing files in a directory

Hello.

Does anyone have some hints or tips on how to list all the files in a folder on C:?.

http://msdn.microsoft.com/en-us/library/aa365200%28v=VS.85%29.aspx

The important functions to mention and to focus on are FindFirstFile ( to retreive the file handle to the first file in the sepcified directoy), FindNextFile (continuously called to get the next file´s handle)
and FindClose (to close the file handle after You are finished)
Thanks for the link :) now i get something i dont understand here

Error 2 error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'WCHAR [260]' to 'const std::string &

and

Error 2 error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char [17]' to 'LPCWSTR'
UNICODE... Disable unicode or use L"[Yor Text Here]" or _T("[Your Text Here]")
It worked but now it tells me

Error 2 error C2664: 'FindFirstFileA' : cannot convert parameter 2 from 'WIN32_FIND_DATA' to 'LPWIN32_FIND_DATAA'
Either disable UNICODE OR use the macros... or use the TEXT-Macro...

EDIT: The W-appendix after a function´s name indicates the unicode-version of the function , and A indicates ANSI (non-unicode):P...
Last edited on
Error 2 error C2664: 'FindFirstFileA' : cannot convert parameter 2 from 'WIN32_FIND_DATA' to 'LPWIN32_FIND_DATAA'

'FindFirstFileA' need an address of 'WIN32_FIND_DATA' object , but you give it a object of 'WIN32_FIND_DATA' , you can use & before your var
Topic archived. No new replies allowed.