C、C++文件夹文件遍历
来源:互联网 发布:软件模块起英文名 编辑:程序博客网 时间:2024/05/14 22:13
C/C++文件夹文件遍历
#include<iostream>#include<string>#include<io.h>#include<time.h>using namespace std;void visit(string path) //文件夹的遍历{ struct _finddata_t filefind; //文件结构体 string str_curr = path + "\\*.*"; struct tm *time; //文件时间 long handle=_findfirst(str_curr.c_str(), &filefind); if(handle == -1) // 判断是否为空文件夹 { return; } while(!(_findnext(handle, &filefind))) { if(strcmp(filefind.name,"..") == 0 || strcmp(filefind.name,".") == 0) { continue; } if((_A_SUBDIR==filefind.attrib)) //是目录 { time = gmtime(&filefind.time_access); cout<<filefind.name << "\t"; cout << time->tm_year << "-" << time->tm_mon << "-" << time->tm_mday; cout << "\t"; cout << time->tm_hour << "-" << time->tm_min << "-" << time->tm_sec << endl; string prepath = path +"\\" + filefind.name; visit(prepath); } else//不是目录,是文件 { cout<<filefind.name<<endl; } } _findclose(handle);}int main(){ string path; cout<<"请输入目录"<<endl; cin>>path; visit(path); return 0;}/*struct _finddata_t{ unsigned attrib; //文件属性的存储位置 time_t time_create; //文件创建时间 time_t time_access; //文件最后一次被访问的时间 time_t time_write; //文件最后一次被修改的时间。 fsize_t size; //文件的字节数 char name[_MAX_FNAME]; //文件的文件名};*/
0 0
- C、C++文件夹文件遍历
- C Windows 读取文件夹 遍历文件
- c遍历所有文件夹中的文件
- linux C语言遍历文件夹所有文件
- c遍历文件夹
- C/C++遍历文件夹
- c 遍历文件夹
- C/C++ 遍历文件夹
- C#--遍历文件夹实例
- C/C++遍历文件夹
- c/c++遍历文件夹
- C#.Net遍历远程文件夹下的所有文件
- C#.Net遍历本地文件夹下的所有文件
- 如何用C遍历一个文件夹中的所有文件
- c/c++实现遍历文件夹下特定的文件
- C语言 遍历文件夹查找最后创建的文件
- C语言在linux下递归遍历文件夹中的文件
- 用C遍历文件夹下的所有文件
- jq特效库
- 十进制小数转化为二进制小数
- httpclient 3.0 访问rest
- Linux中shell提示符定制
- Monkey命令强化
- C、C++文件夹文件遍历
- Vim使用技巧
- Kettle中的表输出连接Phoenix,将数据导出到Phoenix中的表
- LeetCode题解-25-Reverse Nodes in k-Group
- Python 小练习 阶乘
- PRISM概率模型检测器初使用--骰子模型(改进版)
- Python中::(双冒号)的用法
- Makefile
- Java 连接Oracle 报错: java.sql.SQLException: ORA-28040: No matching authentication protocol