#include <iostream>
#include <io.h>
#include <direct.h>
using namespace std;
void listdir(string dir)
{
string newdir = dir + "\\*.*";
intptr_t handle;
struct _finddata_t fileinfo;
handle = _findfirst(newdir.c_str(), &fileinfo);
if (handle == -1)
{
cout << "无文件" << endl;
system("pause");
return ;
}
do
{
if (fileinfo.attrib & _A_SUBDIR) // 如果是文件夹
{
cout << fileinfo.name << endl;
if (strcmp(fileinfo.name, ".") == 0 || strcmp(fileinfo.name, "..") == 0)
{
continue;
}
newdir = dir + "\\" + fileinfo.name;
cout << newdir.c_str() << endl;
listdir(newdir.c_str());
cout << newdir.c_str() << endl;
if (_rmdir(newdir.c_str()) == 0)
{
cout << "删除空文件夹成功" << endl;
}
else
{
cout << "删除空文件夹失败" << endl;
}
}
else
{
cout << fileinfo.name << endl;
char* p = strstr(fileinfo.name, "(1)");
if (p != NULL)
{
string file_path = dir + "\\" + fileinfo.name;
cout << file_path.c_str() << endl;
if (remove(file_path.c_str()) == 0)
{
cout << "删除文件成功" << endl;
}
else
{
cout << "删除文件失败" << endl;
}
}
}
} while (!_findnext(handle, &fileinfo));
_findclose(handle);
return;
}
int main()
{
string dir = "D:\\Mini ROS小车附送资料";
listdir(dir);
system("pause");
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
windows文件去重demo,修改文件路径即可使用
共26个文件
tlog:6个
pdb:2个
vsidx:2个
需积分: 0 0 下载量 111 浏览量
2023-04-11
14:52:46
上传
评论
收藏 12.31MB ZIP 举报
温馨提示
windows文件去重demo,修改文件路径即可使用
资源推荐
资源详情
资源评论
收起资源包目录
file_remove_duplicates.zip (26个子文件)
file_remove_duplicates
.vs
Project1
v17
Browse.VC.db 16.13MB
.suo 29KB
ipch
AutoPCH
1d4db80b0e6c7312
MAIN.ipch 36.13MB
FileContentIndex
read.lock 0B
62828c17-e458-4fc8-a8ef-4e63f9a8e959.vsidx 7KB
merges
7196dc2b-13b8-4357-8fc6-f8d1de8525c1.vsidx 4KB
x64
Debug
Project1.pdb 1.31MB
Project1.exe 99KB
Project1
main.cpp 1KB
x64
Debug
vc143.pdb 396KB
Project1.tlog
CL.write.1.tlog 460B
CL.command.1.tlog 714B
link.command.1.tlog 1KB
link.read.1.tlog 3KB
link.write.1.tlog 464B
Project1.lastbuildstate 165B
CL.read.1.tlog 20KB
Project1.exe.recipe 301B
Project1.ilk 872KB
vc143.idb 163KB
Project1.log 97B
main.obj 259KB
Project1.vcxproj 6KB
Project1.vcxproj.user 168B
Project1.vcxproj.filters 966B
Project1.sln 1KB
共 26 条
- 1
资源评论
lrzss
- 粉丝: 20
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功