How to get list of files in a directory programmatically

后端 未结 2 1996
情深已故
情深已故 2020-12-22 10:03

I have searched everything , but no source codes i found work with VS C++ 2008,
Do you have any way to find list of files in a directory programmatically?

I am u

2条回答
  •  萌比男神i
    2020-12-22 10:32

    This shall find the list of files in C: drive, It doesn't use dirent.h just simple file handling api's,
    FindFirstFile & FindNextFile

    #include 
    
    int main(int argc, char* argv[])
    {
       WIN32_FIND_DATA search_data;
    
       memset(&search_data, 0, sizeof(WIN32_FIND_DATA));
    
       HANDLE handle = FindFirstFile("c:\\*", &search_data);
    
       while(handle != INVALID_HANDLE_VALUE)
       {
          cout<<"\n"<

    You should have a look at the standard api's on the msdn website.

提交回复
热议问题