C/C++/aaa

CFileFind 사용 예제

김컴맹 2012. 3. 22. 13:34
반응형

CFileFind cfileFind;
BOOL IsFile;

//MKT---모든 파일을 다 찾도록 합니다
IsFile=cfileFind.FindFile(strSeletedItem + "\\*.*");
CString strTempPath;
char* P_FileList = new char[100];


//MKT---프로젝트의 시작 경로를 고정으로 기억시키기 위함 입니다.
if(strTemp == "")
{
strTemp=strSeletedItem;
}


while(IsFile)
{
IsFile=cfileFind.FindNextFileA();
//MKT---.과 ..을 만나면 무시 합니다.
if(cfileFind.IsDots())
{
continue;
}
//MKT--- 디렉토리 라면 해당 디렉토리의 절대 경로를 가져와 재귀호출 합니다.
if(cfileFind.IsDirectory())
{
strTempPath = cfileFind.GetFilePath();
M_GetFileList(cfile, strTempPath);
}

//MKT---디렉토리가 아닌 파일이면 라이트를 위한 단계를 거칩니다.
if(!cfileFind.IsDirectory())
{
int ii=0;
//MKT---RootDir의 길이를 구합니다.
ii = strTemp.GetLength();
//MKT---파일이라면 이에 대한 절대경로를 구합니다.
strTempPath = cfileFind.GetFilePath();
//MKT---줄바꿈을 입력 합니다.
strTempPath += "\r\n";
//MKT---RootDir를 지우고 저장 합니다.
strTempPath.Delete(0, ii+1);
//MKT---해당 문자열을 파일로 저장하기 위한 단계 입니다.
P_FileList=strTempPath.GetBuffer(0);
strTempPath.ReleaseBuffer();
//MKT---받아온 포인터를 통해 파일을 기록 합니다.
cfile->Write(P_FileList, strTempPath.GetLength());
}
}








본 게시물은 , 데브피아(www.devpia.com)의 문경택 님이 작성하신 글입니다.
반응형

'C/C++ > aaa' 카테고리의 다른 글

GetProcAddress  (0) 2012.05.16
ActiveX inf 파일  (0) 2012.04.12
ActiveX CLSID 변경  (0) 2012.03.22
ZeroMemory, memset  (0) 2012.03.12
AFX_MANAGE_STATE(AfxGetStaticModuleState())  (0) 2012.03.11