フォルダを削除する。
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
フォルダを作成する。
BOOL xxxxxx::CreateFolder(LPCTSTR lpFolderName)
{
// 指定したフォルダをチェックと作成
CString folder = _T("");
LPSECURITY_ATTRIBUTES lpSecurity;
CStringArray splitFolder;
this->SplitFolder( lpFolderName, splitFolder );
for( int i = 0; i < splitFolder.GetSize() - 1; i++ ){
folder += splitFolder.GetAt(i);
if( !this->CheckFolderPath( folder ) ){
if(::CreateDirectory( /*(LPCWSTR)*/folder, NULL ) == NULL ){
::AfxMessageBox( _T("フォルダの作成に失敗しました。") );
return FALSE;
}
}
folder += _T("\\");
}
return TRUE;
}
BOOL xxxxxx::CreateFolder(LPCTSTR lpFolderName)
{
// 指定したフォルダをチェックと作成
CString folder = _T("");
LPSECURITY_ATTRIBUTES lpSecurity;
CStringArray splitFolder;
this->SplitFolder( lpFolderName, splitFolder );
for( int i = 0; i < splitFolder.GetSize() - 1; i++ ){
folder += splitFolder.GetAt(i);
if( !this->CheckFolderPath( folder ) ){
if(::CreateDirectory( /*(LPCWSTR)*/folder, NULL ) == NULL ){
::AfxMessageBox( _T("フォルダの作成に失敗しました。") );
return FALSE;
}
}
folder += _T("\\");
}
return TRUE;
}