티스토리 뷰

윈도우즈에서 파일리스트 가져오기

#include <windows.h>
#include <iostream>

int main()
{
    WIN32_FIND_DATA data;
    HANDLE hFind = FindFirstFile("C:\\semester2", &data);      // DIRECTORY

    if ( hFind != INVALID_HANDLE_VALUE ) {
        do {
            std::cout << data.cFileName << std::endl;
        } while (FindNextFile(hFind, &data));
        FindClose(hFind);
    }
}
HANDLE hFind = FindFirstFile("C:\\semester2", &data);       // DIRECTORY

You got the directory because that's what you asked for. If you want the files, ask for them:

HANDLE hFind = FindFirstFile("C:\\semester2\\*", &data);  // FILES

(You can instead use *.* if you prefer, but apparently this only works because of a backwards compatibility hack so should probably be avoided. See comments and RbMm's answer.)

즉, 파일 path 자리에 “D:/Work/*.mp4” 로 쓰면 mp4 파일 리스트로 접근 가능. 
do에서 파일 처리하고, nextFile로 접근해서 처리
그리고 data는 WIN32_FIND_DATA 포맷인데 이를 string 처럼 쓰기 위해서 cFileName에 접근하면 됨.
string vidname = vid_path + data.cFileName


'코딩' 카테고리의 다른 글

Dense flow  (0) 2018.03.20
OpenCV imshow 관련  (0) 2018.02.27
sublime으로 latex 환경 셋팅  (0) 2017.12.29
OpenCV 3.3.1 Visual Studio 2013으로 make 하기  (0) 2017.11.09
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함