没有合适的资源?快使用搜索试试~ 我知道了~
用C/C++ 列出指定目录的所有文件夹和文件
4星 · 超过85%的资源 需积分: 50 116 下载量 166 浏览量
2011-01-05
22:40:22
上传
评论
收藏 949B TXT 举报
温馨提示
试读
2页
用C/C++ 列出指定目录的所有文件夹和文件用
资源推荐
资源详情
资源评论
#include<iostream>
#include<string>
#include<io.h>
#include<stdio.h>
using namespace std;
void filesearch(string path,int layer)
{
struct _finddata_t filefind;
string curr=path+"\\*.*";
int done=0,i,handle;
if((handle=_findfirst(curr.c_str(),&filefind))==-1)return;
while(!(done=_findnext(handle,&filefind)))
{
if(!strcmp(filefind.name,".."))continue;
for(i=0;i<layer;i++)cout<<" |- ";
if ((_A_SUBDIR==filefind.attrib))
{
cout<<filefind.name<<"(dir)"<<endl;
curr=path+"\\"+filefind.name;
filesearch(curr,layer+1);
}
else
{
cout<<filefind.name<<endl;
}
}
_findclose(handle);
}
int main()
{
#include<string>
#include<io.h>
#include<stdio.h>
using namespace std;
void filesearch(string path,int layer)
{
struct _finddata_t filefind;
string curr=path+"\\*.*";
int done=0,i,handle;
if((handle=_findfirst(curr.c_str(),&filefind))==-1)return;
while(!(done=_findnext(handle,&filefind)))
{
if(!strcmp(filefind.name,".."))continue;
for(i=0;i<layer;i++)cout<<" |- ";
if ((_A_SUBDIR==filefind.attrib))
{
cout<<filefind.name<<"(dir)"<<endl;
curr=path+"\\"+filefind.name;
filesearch(curr,layer+1);
}
else
{
cout<<filefind.name<<endl;
}
}
_findclose(handle);
}
int main()
{
S_china
- 粉丝: 7
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页