C++判断文件夹是否存在

判断一个文件夹是否存在

#include 
#include 

using namespace std;

int main()
{
    std::string path = "./post";
    DIR * dir;                   // return value for opendir()
    dir = opendir(path.data());
    if( dir == nullptr )
    {
        cout<< "dir don't exist. "<< endl;
    }
    else {
        cout << "open dir success." << endl;
    }
    return 0;
}

 

你可能感兴趣的:(C++)