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

判断一个文件夹是否存在

#include <iostream>
#include <dirent.h>

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;
}

猜你喜欢

转载自blog.csdn.net/weixin_42439026/article/details/89788249