//
/* .h */
//
#pragma once
#include <string>
using namespace std;
class Folder_Toor
{
public:
Folder_Toor(string folderPath);
~Folder_Toor();
void getFilesNum();
void getFiles(); // 获得文件夹下所有文件
void getFilesNum(string exten);
void getFiles(string exten); //获得指定后缀名的的文件
void removeAllFiles(); // 删除文件
void removeAllFiles(string exten);
string m_folderPath;
bool m_folderIsExist = false;
bool m_folderIsEmpty = true;
string *m_filesName;
int m_filesNum = 0;
};
//
/* .cpp */
//
#include "Folder_Toor.h"
#include <string>
#include <corecrt_io.h>
#include <direct.h>
#include <iostream>
using namespace std;
Folder_Toor::Folder_Toor(string folderPath)
{
this->m_folderPath = folderPath;
if ((_access(m_folderPath.c_str(), 0)) != -1)
{
this->m_folderIsExist = true;
}
}
Folder_Toor::~Folder_Toor()
{
if (this->m_filesName != NULL) { delete m_filesName; }
}
voi
C++获取目录下所有文件及删除操作
最新推荐文章于 2023-07-20 16:24:16 发布