아래와 같이 하면 c:\temp 디렉토리 밑에 있는 모든 파일과 디렉토리들이 recursive하게 c\temp2 디렉토리에 복사됩니다.
int CopyFiles(const char* srcfiles,const char* dstdir)
{
SHFILEOPSTRUCT sfop;
ZeroMemory(&sfop,sizeof(sfop));
sfop.wFunc = FO_COPY;
sfop.pFrom = srcfiles;
sfop.pTo = dstdir;
sfop.fFlags = FOF_NOCONFIRMMKDIR /*|FOF_SILENT*/ ;
return SHFileOperation(&sfop);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(0!=CopyFiles("c:\\temp\\*.*\0","c:\\temp2\0")){
ShowMessage("Error!");
}
}
ymin 님이 쓰신 글 :
: 감사합니다. 간단한 예제를 좀 보여 줄수 있나요?
: 그리고 디렉토리 복사의 경우도 좀 가르쳐 주시겠습니까?
: 부탁합니다.
: .
: 님이 쓰신 글 :
: : ymin 님이 쓰신 글 :
: : : 프로그램 안에서 실행중에 파일과 디렉토리를 복사 혹은 이동하려면
: : : 어떤 명령어를 사용하면 되나요?
: :
: : BOOL CopyFile(
: : LPCTSTR lpExistingFileName, // pointer to name of an existing file
: : LPCTSTR lpNewFileName, // pointer to filename to copy to
: : BOOL bFailIfExists // flag for operation if file exists
: : );
: :
http://msdn.microsoft.com/library/en-us/fileio/fs/copyfile.asp?frame=true
: :
: : BOOL CopyFileEx(
: : LPCWSTR lpExistingFileName, // pointer to name of an existing file
: : LPCWSTR lpNewFileName, // pointer to filename to copy to
: : LPPROGRESS_ROUTINE lpProgressRoutine, // pointer to the callback function
: : LPVOID lpData, // to be passed to the callback function
: : LPBOOL pbCancel, // flag that can be used to cancel the operation
: : DWORD dwCopyFlags // flags that specify how the file is copied
: : );
: :
http://msdn.microsoft.com/library/en-us/fileio/fs/copyfileex.asp?frame=true
: :
: : int SHFileOperation(
: : LPSHFILEOPSTRUCT lpFileOp
: : );
: :
http://msdn.microsoft.com/library/en-us/wceshellui5/html/wce50lrfSHFileOperation.asp?frame=true