フォルダを削除する。
BOOL xxxxxx::DeleteFolder(LPCTSTR loFolder)
{
CFileFind fFind;
CString strFolderPath = loFolder;
strFolderPath.TrimRight( _T("\\") );
strFolderPath += _T("\\*.*");
if( !fFind.FindFile( strFolderPath ) )
return FALSE;
BOOL bRet = TRUE;
while( bRet ){
bRet = fFind.FindNextFileW();
if( fFind.IsDots() )
continue;
CString strPath;
strPath.Format( _T("%s\\%s"), loFolder, fFind.GetFileName() );
if( fFind.IsDirectory() )
DeleteItem( strPath );
else
DeleteFile( strPath );
}
fFind.Close();
return RemoveDirectory( loFolder );
}
BOOL xxxxxx::DeleteFolder(LPCTSTR loFolder)
{
CFileFind fFind;
CString strFolderPath = loFolder;
strFolderPath.TrimRight( _T("\\") );
strFolderPath += _T("\\*.*");
if( !fFind.FindFile( strFolderPath ) )
return FALSE;
BOOL bRet = TRUE;
while( bRet ){
bRet = fFind.FindNextFileW();
if( fFind.IsDots() )
continue;
CString strPath;
strPath.Format( _T("%s\\%s"), loFolder, fFind.GetFileName() );
if( fFind.IsDirectory() )
DeleteItem( strPath );
else
DeleteFile( strPath );
}
fFind.Close();
return RemoveDirectory( loFolder );
}
PR
この記事にコメントする