태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.


2008/11/17 10:18

특정 폴더의 파일 찾기


특정 폴더의 파일들을 검색하여 리스트 박스에 뿌려 주기..

아래 코드는 텍스트 상자로 부터 폴더명을 입력 받고, 폴더를 검색하여 폴더가 존재 하고

그 하위에 파일이 존재 하면, 리스트 박스에 파일명을 뿌려 준다.



void CNestingInputPg::OnEnChangeBlocktext()

{

 UpdateData(TRUE);

 m_PartFileList.ResetContent();

 m_Block = m_BlockText;

 CString path;

 path.Format("c:\\CADPart\\%s\\%s",m_Hosun,m_Block);

 CFileFind finder;

 bool working = finder.FindFile( path + "\\*.*" );

 while ( working )

 {

working = finder.FindNextFile();

if (!finder.IsDirectory())

CString curfile = finder.GetFileName();

m_PartFileList.AddString(curfile);

}

 }

 finder.Close();

}




혹 파일명이 아닌, 폴더명을 검색하고 싶다면.. 아래와 같이 하면 된다.

아래는 폴더를 검색하여 콤보 박스에 뿌려 주는 코드 이다.

하위 폴더는 검색에서 제외 시켰다.

void CNestingInputPg::OnCbnDropdownHosuncombo()

{

 m_HosunCombo.ResetContent();

 CString path;

 path.Format("c:\\CADPart\\*.*");

 CFileFind finder;

 bool working = finder.FindFile(path);

 while ( working )

 {

  working = finder.FindNextFile();

  if(finder.IsDots())

   continue;

  CString curfile = finder.GetFileName();

  m_HosunCombo.AddString(curfile);

 }

 finder.Close();

}

저작자 표시 비영리
Trackback 0 Comment 0