赞
踩
目录
- #include <iostream>
- #include <string>
- #include <io.h>
-
- int run_main()
- {
- // 图片所在文件夹,路径不要有中文
- std::string imgRoot = "D:/";
-
- _finddata64i32_t fileInfo;
- intptr_t hFile = _findfirst((imgRoot + "\\*.*").c_str(), &fileInfo);
-
- if (hFile == -1) {
- std::cout << "not find image!\n";
- return -1;
- }
-
- static int count = 0;
-
- do
- {
- std::string imgPath = imgRoot + "/" + std::string(fileInfo.name);
-
- std::cout << imgPath << std::endl;
-
- count++;
- } while (_findnext(hFile, &fileInfo) == 0);
-
- return EXIT_SUCCESS;
- }
这里需要用到 c++ 17
- #include <iostream>
- #include <vector>
- #include <string>
- #include <io.h>
- #include <filesystem>
-
- void curDir()
- {
- std::string imgRoot = "D:/";
- using recursive_directory_iterator = std::filesystem::recursive_directory_iterator;
- for (const auto& dirEntry : recursive_directory_iterator(imgRoot))
- {
- std::string filePath = dirEntry.path().string();
- std::cout << filePath << std::endl;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。