????3.??windows??????API????FindFirstFile(...):
????(1)????????????:
#define _WIN32_WINNT 0x0400
#include "windows.h"
int
main(int argc?? char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
printf ("Target file is %s. "?? argv[1]);
hFind = FindFirstFile(argv[1]?? &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
printf ("Invalid File Handle. Get Last Error reports %d "?? GetLastError ());
} else {
printf ("The first file found is %s "?? FindFileData.cFileName);
FindClose(hFind);
}
return (0);
}
????(2)??????????????
///??????????飺
bool  CheckFolderExist(const string &strPath)
{
WIN32_FIND_DATA  wfd;
bool rValue = false;
HANDLE hFind = FindFirstFile(strPath.c_str()?? &wfd);
if ((hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
rValue = true;
}
FindClose(hFind);
return rValue;
}
    4.???boost??filesystem????exists????
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>
int GetFilePath(std::string &strFilePath)
{
string strPath;
int nRes = 0;
//???·??
strPath = "D:/myTest/Test1/Test2";
namespace fs = boost::filesystem;
//·????????
fs::path full_path( fs::initial_path() );
full_path = fs::system_complete( fs::path(strPath?? fs::native ) );
//?ж??????????????????????????????
if ( !fs::exists( full_path ) )
{
// ???????????
bool bRet = fs::create_directories(full_path);
if (false == bRet)
{
return -1;
}
}
strFilePath = full_path.native_directory_string();
return 0;
}