简体   繁体   中英

Iterating through the files in a folder (C++)

I'm trying to search through all of the files in a folder on my computer. A lot of sources recommend using Boost, but I've been told that the following code could work.

WIN32_FIND_DATA currentFile;

HANDLE searchHandle = FindFirstFile("C:\\MyFolder\\", &currentFile);

do
{
    /*Do something each time it finds a file*/
} while (FindNextFile(searchHandle, &currentFile));

The loop should respond each time it encounters a new file. There are several files in the folder I'm using, but the loop only works once. How can I fix it?

我相信他们在这里使用“C:\\\\ MyFolder \\ *”*作为所有人的通配符。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM