C/C++判断文件夹是否存在以及创建、删除文件夹
(2019-03-22 10:26:03)| 分类: c#c c |
1.Windows下创建单个文件夹示例:
#include
#include
using
namespace std;
int
main()
{
string dir = "./test";
if (_access(dir.c_str(), 0) == -1)
{
cout << dir << " is not existing"
<< endl;
int flag = _mkdir(dir.c_str());
if (flag == 0)
{
cout << "make successfully" <<
endl;
}
else {
cout << "make fsiled" << endl;
}
}
if (_access(dir.c_str(), 0) == 0)
{
cout << dir << " exists" <<
endl;
cout << "now delete it" <<
endl;
int flag = _rmdir(dir.c_str());
if (flag == 0)
{
cout << "delete it successfully" <<
endl;
}
else {
cout << "delete it errorly" <<
endl;

加载中…