VC判断目录存在与创建录目

#include <iostream>
#include <fstream>
#include <string>
#include <sys/stat.h>
#include <direct.h>

void main()
{

    struct _stat file_state;

    std::string dir="test_dir";

    if ((_stat(dir.data(),&file_state) ==0))
    {
        printf("exist");
    }
    else
    {
        _mkdir(dir.data());

        printf("crested at xxx");
    }


    system("pause");
}
posted @ 2012-11-26 15:34  大约  阅读(152)  评论(0编辑  收藏  举报