반응형
#include <windows.h>
#include <iostream>
#include <cstdio>
#include <tchar.h>

#define UNICODE

void WCharToChar(const wchar_t* pwstrSrc, char pstrDest[])
{
    int nLen = (int)wcslen(pwstrSrc);
    wcstombs(pstrDest, pwstrSrc, nLen + 1);
}


int main(){
    _wsetlocale(LC_ALL, _T("korean"));
    WIN32_FIND_DATA  findFileData;
    HANDLE hFileHandle;

    // szDir에 뒤지고자 하는 디렉토리의 경로명을 준다. 예를 들면 "C:\\TEMP\\*.*"
    // 찾아진 파일의 속성은 findFileData의 dwFileAttributes를 살펴본다.
    hFileHandle = FindFirstFile(L"S:\졸업프로젝트\Log\_SensorData\*", &findFileData);
    if (hFileHandle != INVALID_HANDLE_VALUE)   // 파일을 찾은 경우 
    {
        // 찾은 파일의 이름은 cFileName 필드로 들어온다.
        // 다음 파일을 찾는다.
        while (FindNextFile(hFileHandle, &findFileData)){
            char fName[2048];
            WCharToChar(findFileData.cFileName, fName);
            _tprintf(_T("%s\n"), findFileData.cFileName);
        }
        FindClose(hFileHandle);
    }
}
반응형

댓글을 달아 주세요