搜寻文件夹中某一后缀的文件名,并且输出到文件
2015-04-13 14:50
239 查看
/* ************************************************** Title: 按后缀名查找文件 ************************************************** Date:2015/04/13 ************************************************** author:刘旭 ************************************************** */ #include <iostream> #include <fstream> #include <string> #include <cstring> #include <io.h> using namespace std; int main(int argc,char *argv[]) { ofstream fout; string str_file = ""; intptr_t hflie = 0; int num = 0; _finddata_t flie; cin>>str_file; string str_dir = str_file + "_out.txt"; str_file = "*." + str_file; fout.open(str_dir.c_str()); if(false == fout.is_open()) { return 0; } hflie = _findfirst(str_file.c_str(), &flie); if(-1 == hflie) { fout<<"num = "<<num<<endl; fout.close(); return 0; } do { if(1 == strlen(flie.name) && '.' == flie.name[0] ||2 == strlen(flie.name) && '.' == flie.name[0] == flie.name[1]) { continue; } else { num++; fout<<flie.name<<endl; } } while(0 == _findnext(hflie, &flie)); cout<<"num = "<<num<<endl; fout<<"num = "<<num<<endl; fout.close(); return 0; }
相关文章推荐
- shell查找某个文件夹的文件名并将其输出到某一个文件
- 把文件夹下所有后缀为自己--想要的文件名称--全部输出出来
- 遍历文件和文件夹 获取文件名后缀
- 输出某个文件夹下面的所有文件名 后缀 及路径(linux)
- [java] 遍历输出D盘文件夹中以a开头的txt文件,并且统计个数
- fso获取文件夹下文件个数和显示文件名(无后缀)
- ruby遍历文件夹下所有文件,输出文件名(migrate报错处理)
- 简易遍历输出C盘java文件夹所有文件,并且拷贝到E盘。
- 遇到问题-----ftp---windows----打开FTP文件夹出错--windows无法访问此文件夹。请确保输入的文件名是否正确,并且您有权访问此文件
- 遍历输出文件内的文件夹和文件名
- ftp文件夹错误:windows无法访问此文件夹,请确保输入的文件名是否正确,并且您有权访问此文件
- c语言 运行cmd 查询某个文件夹内文件名并且输出
- 用cmd的FC命令 对比两个文件夹内容不同并将文件名输出到文件中
- 读取文件夹下的文件数量 并输出文件名
- windows下创建没有文件名只有后缀的文件夹或者文件
- 编写一个函数,能输出文件夹下的文件列表,文件名通过控制台输入
- 输出文件夹内所有文件后缀
- ftp连接报错: windows无法访问此文件夹。请确保输入的文件名是否正确,并且您有权访问此文件-
- Java读取文件目录和文件,并且按照文件层次输出文件名和目录名。