kyuseo의 게임 프로그래밍
DeleteAllFile :: 디렉토리(폴더)의 모든 파일을 제거, 삭제한다. 본문
디렉토리(폴더)의 모든 파일을 제거, 삭제하는 함수 DeleteAllFile 입니다.
파일을 삭제하는 함수이므로 주의해서 사용하시기 바랍니다.
함수 |
핵심 코드는 CFileFind, FindFile, DeleteFile 입니다.
void DeleteAllFile( LPCSTR szDir ) { CString strName; strName.Format( "%s\\*.*", szDir );
CFileFind ff; BOOL bFind = ff.FindFile( strName );
while( bFind ) { bFind = ff.FindNextFile();
if( ff.IsDots() == TRUE || ff.IsDirectory() == TRUE ) continue;
DeleteFile( ff.GetFilePath() ); }
ff.Close(); } |
사용법 |
매우 간단한 사용법을 가지고 있습니다.
DeleteAllFile( "C:\\temp" ); |