BOOL DeleteDirectoryFile(LPCTSTR RootDir)
{
if (RootDir == NULL) { return FALSE; }
BOOL bRval = FALSE;
CString szNextDirPath = _T("");
CString szRoot = _T(""); // 해당 디렉토리의 모든 파일을 검사한다.
szRoot.Format(_T("%s\\*.*"), RootDir);
CFileFind find; bRval = find.FindFile(szRoot);
if (bRval == FALSE)
{ return bRval; }
while (bRval)
{
bRval = find.FindNextFile(); // . or .. 인 경우 무시 한다.
if (find.IsDots() == FALSE)
{
// Directory 일 경우 재귀호출 한다.
if (find.IsDirectory())
{
DeleteDirectoryFile(find.GetFilePath());
}
// file일 경우 삭제
else
{
bRval = DeleteFile(find.GetFilePath());
}
}
}
find.Close();
bRval = RemoveDirectory(RootDir);
return bRval;
}
'프로그래밍 > VC++ 개발 코딩' 카테고리의 다른 글
txt 파일 읽어오기 (0) | 2020.10.08 |
---|---|
MFC 에서 ListBox에 출력 된 정보들을 *.txt 파일로 저장할 때 (0) | 2020.06.09 |
lpvoid 타입에 float 변환하기 (0) | 2020.02.22 |
CString to string, string to CString 변환 (0) | 2019.10.22 |
비쥬얼 스튜디오 - 단위 테스트(유닛 테스트) (0) | 2019.10.03 |