#include ".\myfolder.h" #include "shellapi.h" #include "shlwapi.h" #include "stdio.h" MyFolder::MyFolder(void) { } MyFolder::~MyFolder(void) { } BOOL MyFolder::CopyFoler( const TCHAR* pszFrom, const TCHAR* pszTo ) { //¸ÕÀú pszTo Æú´õÀÇ µð·ºÅ丮¸¦ »ý¼ºÇÑ´Ù. CreteFolder( pszTo ); TCHAR fromPath[MAX_PATH+2]; memset(fromPath, 0, sizeof(fromPath)); strcpy(fromPath, pszFrom); TCHAR toPath[MAX_PATH+2]; memset(toPath, 0, sizeof(toPath)); strcpy(toPath, pszTo); SHFILEOPSTRUCT shfo = {0}; ZeroMemory(&shfo, sizeof shfo); shfo.hwnd = NULL; shfo.wFunc = FO_COPY; shfo.fFlags = FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION; shfo.lpszProgressTitle = "Æú´õ º¹»ç"; shfo.fAnyOperationsAborted = false; shfo.pTo = toPath; shfo.pFrom = fromPath; int nResult = SHFileOperation(&shfo); if( nResult == 0 ) return TRUE; return FALSE; } BOOL MyFolder::DeleteFoler( const TCHAR* pszPath ) { BOOL bRet = TRUE; SHFILEOPSTRUCT *SHELL = new SHFILEOPSTRUCT; memset( (void*)SHELL,0,sizeof(SHFILEOPSTRUCT) ); char buff[255]; memset(buff,'\0',sizeof(buff)); sprintf(buff, "%s\0\0", pszPath ); //2°³ ³Ö´Â°Ô Áß¿ä.. SHELL->wFunc = FO_DELETE; SHELL->pFrom = buff; SHELL->fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION; if( strstr( pszPath, "*") ) //wild card { SHELL->fFlags |= FOF_FILESONLY; SHELL->fFlags |= FOF_MULTIDESTFILES; } if( SHFileOperation(SHELL) != 0) bRet = FALSE; delete SHELL; return bRet; } void MyFolder::CreteFolder( const TCHAR* pszFoletPath ) { int len = (int)strlen(pszFoletPath) + 1; char *buf = new char[len]; strcpy(buf, pszFoletPath); for(int idx = 0; idx < len; idx++) { if(buf[idx] && buf[idx] != '\\') continue; buf[idx] = '\0'; if(PathIsDirectory(buf) == FALSE) CreateDirectory(buf, NULL); buf[idx] = '\\'; } delete[] buf; }