BOOL WINAPI CreateDirectoryEx(CString strPath)
{
CStringArray path;
CString str = strPath;
CreateDirectory(str, NULL);
if (str.ReverseFind ('\\') > 2)
path.Add (str);
while (str.ReverseFind ('\\') > 2)
{
str = str.Left (str.ReverseFind ('\\'));
path.Add (str);
}
int n = path.GetUpperBound ();
while (n >= 0)
{
CreateDirectory (path.GetAt(n), NULL);
path.RemoveAt (n);
n = path.GetUpperBound ();
}
return TRUE;//temp
}
BOOL WINAPI DeleteDirectory(CString path)
{
WIN32_FIND_DATA wfd;
HANDLE handle = NULL;
int hr =1;
TCHAR tempFileFind[MAX_PATH];
sprintf(tempFileFind,"%s\\*.*",path);
handle =(HANDLE) FindFirstFile(tempFileFind,&wfd);
if(handle)
while(hr)
{
if(strcmp(wfd.cFileName, ".") && strcmp(wfd.cFileName,".."))
{
TCHAR foundFileName[MAX_PATH];
strcpy(foundFileName,wfd.cFileName);
if(wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
TCHAR tempDir[200];
sprintf(tempDir,"%s\\%s",path,foundFileName);
DeleteDirectory(tempDir);
}
else
{
TCHAR tempFileName[200];
sprintf(tempFileName,"%s\\%s",path,foundFileName);
DeleteFile(tempFileName);
}
}
hr = FindNextFile(handle,&wfd);
}
FindClose(handle);
if(!RemoveDirectory(path))
return FALSE;
return TRUE;
}