BOOL CreatePath(LPCTSTR lpszDir)
{
if(lpszDir==NULL || _tcslen(lpszDir)==0)
return FALSE;
// base case . . .if directory exists
if(IsPathExist(lpszDir))
return TRUE;
CString strDir(lpszDir);
if(strDir.Right(1) == "//")
strDir = strDir.Left(strDir.GetLength()-1);
// recursive call, one less directory
int nFound = strDir.ReverseFind('//');
CString strSubDir = strDir.Left(nFound);
if(! CreatePath(strSubDir) )
return FALSE;
return ::CreateDirectory(strDir,NULL);
}