#include <windows.h>
#include <string>
#include <vector>
using namespace std;
// 核查目录,若目录不存在,创建目录
bool FindOrCreateDirectory( const char* pszPath )
{
WIN32_FIND_DATA fd;
HANDLE hFind = ::FindFirstFile( pszPath, &fd );
while( hFind != INVALID_HANDLE_VALUE )
{
if ( fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
return true;
}
if ( !::CreateDirectory( pszPath, NULL ) )
{
char szDir[MAX_PATH];
sprintf_s( szDir, sizeof(szDir), "创建目录[%s]失败,请检查权限", pszPath );
::MessageBox( NULL, szDir, "创建目录失败", MB_OK|MB_ICONERROR );
return false;
}
return true;
}