易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
软件资源
软件开发
、
小程序制作
、
系统集成与运维
、
空间租用
、
硬件开发
、
视频监控
、
技术咨询与支持
——联系电话:0311-88999002/88999003
首页
/
操作系统
/
Linux
/
C遍历文件夹
C遍历文件夹:
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
void
listFodler(
char
* file);
int
main(
int
argc,
char
*argv[])
{
//char* search="C:\WINDOWS\*.*";
char
search[50];
scanf(
"%s"
,search);
listFodler(search);
system(
"PAUSE"
);
return
0;
}
void
listFodler(
char
* file)
{
strcat(file,
"\*.*"
);
long
handle;
struct
_finddata_t
fileinfo;
handle=_findfirst(file,&fileinfo);
if
(-1==handle)
return
;
printf(
"%s "
,fileinfo.name);
while
(!_findnext(handle,&fileinfo))
{
if
(strcmp(fileinfo.name,
"."
)==0||strcmp(fileinfo.name,
".."
)==0)
{
continue
;
}
if
(fileinfo.attrib==_A_SUBDIR)
{
printf(
"%s is dir----- "
,fileinfo.name);
listFodler(fileinfo.name);
}
printf(
"%s size:%d "
,fileinfo.name,fileinfo.size);
}
_findclose(handle);
}
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图