[code]
// 단일파일
CopyFile("a.txt", "b.txt", FALSE);
[/code]
CopyFile의 마지막 인자에는 TRUE가 있구요.. 이건 중복 파일이 있을때 복사를 하지 않는다는 의미 입니다.
만일 이미 파일이 있는 경우 덥어쓰기를 하고싶다면 TRUE대신 FALSE를 사용하세요.
[code]
// 폴더째 복사
BOOL MyCopyFunc(CString strDestDir)
{
CFileFind objFinder;
BOOL bExist;
bExist = objFinder.FindFile("C:\\SRC\\*.*");
while (bExist) {
bExist = objFinder.FindNextFile();
if (bExist) {
if (objFinder.IsDots()) {
// . 이나 .. 은 생략
}
else if (objFinder.IsDirectory()) {
// 디렉토리
}
else {
// 여기서부터는 일반 파일
CString strDestPath = strDestDir + objFinder.GetFileName();
if (CopyFile(objFinder.GetFilePath(), strDestPath, TRUE /* or FALSE */) == FALSE)
return FALSE;
}
}
}
return TRUE;
}
[/code]
// 단일파일
CopyFile("a.txt", "b.txt", FALSE);
[/code]
CopyFile의 마지막 인자에는 TRUE가 있구요.. 이건 중복 파일이 있을때 복사를 하지 않는다는 의미 입니다.
만일 이미 파일이 있는 경우 덥어쓰기를 하고싶다면 TRUE대신 FALSE를 사용하세요.
[code]
// 폴더째 복사
BOOL MyCopyFunc(CString strDestDir)
{
CFileFind objFinder;
BOOL bExist;
bExist = objFinder.FindFile("C:\\SRC\\*.*");
while (bExist) {
bExist = objFinder.FindNextFile();
if (bExist) {
if (objFinder.IsDots()) {
// . 이나 .. 은 생략
}
else if (objFinder.IsDirectory()) {
// 디렉토리
}
else {
// 여기서부터는 일반 파일
CString strDestPath = strDestDir + objFinder.GetFileName();
if (CopyFile(objFinder.GetFilePath(), strDestPath, TRUE /* or FALSE */) == FALSE)
return FALSE;
}
}
}
return TRUE;
}
[/code]
'Native > C++' 카테고리의 다른 글
구문강조 (0) | 2013.10.02 |
---|---|
파일 속성(SetFileAttributes) (0) | 2013.10.02 |
원도우 설치 경로(GetWindowsDirectory) (0) | 2013.10.02 |
원도우 시스템 경로(GetSystemDirectory) (0) | 2013.10.02 |
[String]addslashes 함수의 구현 (0) | 2013.10.02 |