- 浏览: 258529 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (263)
- mysql (5)
- boost (6)
- 工具 (10)
- IT生活 (7)
- 多线程 (3)
- Ruby (15)
- php (2)
- MongoDB (39)
- 移动互联网 (2)
- 测试 (8)
- c++ (28)
- 书 (1)
- 网站 (3)
- 网络编程 (14)
- 开源软件 (1)
- 分布式计算 (1)
- 得得得 (1)
- php,wordpress (1)
- error (5)
- 编译 (2)
- 学习 (1)
- 杀毒软件 (1)
- dd (0)
- linux (21)
- 数据库 (1)
- STL (1)
- c++/c (5)
- 软件设计 (1)
- 操作系统 (4)
- 库 (2)
- win32 (1)
- s (0)
- openssl (1)
- perl (2)
- debug (1)
- windows (4)
- python (12)
- windows 防火墙 (1)
- vs (1)
- vim (2)
- vc (1)
- 浏览器插件的危害 (1)
- curl (0)
- 判断手机号码合法性的库 (0)
- 地址备注 (0)
- 安装 File::Slurp (1)
- cenos (2)
- shell (1)
- linunx (1)
- internet (1)
- software (1)
- widows (1)
- linux io (1)
- nginx (2)
- 算法 (2)
- google (1)
- protobuf (2)
- tengine (1)
- tools (1)
- lua (2)
- liunx (1)
- vcard (1)
- lua-iconv (1)
- 网络 (2)
- teat (0)
- ldconfig linux (0)
- awk (0)
- grep (0)
- windws (2)
- linux 命令 (1)
- tcp dump (1)
- vmware (1)
- question2answer (2)
- mongdb (1)
- 正则 (1)
- OCR (2)
- Windows Server (1)
最新评论
标签: _findfirst _findnext 杂谈 分类: C
一、这两个函数均在io.h里面。
二、首先了解一下一个文件结构体:
struct _finddata_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
_fsize_t size;
char name[260];
};
time_t,其实就是long
而_fsize_t,就是unsigned long
现在来解释一下结构体的数据成员吧。
attrib,就是所查找文件的属性:_A_ARCH(存档)、_A_HIDDEN(隐藏)、_A_NORMAL(正常)、_A_RDONLY(只读)、 _A_SUBDIR(文件夹)、_A_SYSTEM(系统)。
time_create、time_access和time_write分别是创建文件的时间、最后一次访问文件的时间和文件最后被修改的时间。
size:文件大小
name:文件名。
三、用 _findfirst 和 _findnext 查找文件
1、_findfirst函数:long _findfirst(const char *, struct _finddata_t *);
第一个参数为文件名,可以用"*.*"来查找所有文件,也可以用"*.cpp"来查找.cpp文件。第二个参数是_finddata_t结构体指针。若查找成功,返回文件句柄,若失败,返回-1。
2、_findnext函数:int _findnext(long, struct _finddata_t *);
第一个参数为文件句柄,第二个参数同样为_finddata_t结构体指针。若查找成功,返回0,失败返回-1。
3、_findclose()函数:int _findclose(long);
只有一个参数,文件句柄。若关闭成功返回0,失败返回-1。
四、查找文件例子
#include <io.h>
#include <iostream>
using namespace std;
int main()
{
_finddata_t file;
int k;
long HANDLE;
k = HANDLE = _findfirst( "*.*", &file );
while( k != -1 )
{
cout << file.name << endl;
k = _findnext( HANDLE, &file );
}
_findclose( HANDLE );
return 0;
}
转自:http://blog.sina.com.cn/s/blog_67e046d10100jwdo.html
一、这两个函数均在io.h里面。
二、首先了解一下一个文件结构体:
struct _finddata_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
_fsize_t size;
char name[260];
};
time_t,其实就是long
而_fsize_t,就是unsigned long
现在来解释一下结构体的数据成员吧。
attrib,就是所查找文件的属性:_A_ARCH(存档)、_A_HIDDEN(隐藏)、_A_NORMAL(正常)、_A_RDONLY(只读)、 _A_SUBDIR(文件夹)、_A_SYSTEM(系统)。
time_create、time_access和time_write分别是创建文件的时间、最后一次访问文件的时间和文件最后被修改的时间。
size:文件大小
name:文件名。
三、用 _findfirst 和 _findnext 查找文件
1、_findfirst函数:long _findfirst(const char *, struct _finddata_t *);
第一个参数为文件名,可以用"*.*"来查找所有文件,也可以用"*.cpp"来查找.cpp文件。第二个参数是_finddata_t结构体指针。若查找成功,返回文件句柄,若失败,返回-1。
2、_findnext函数:int _findnext(long, struct _finddata_t *);
第一个参数为文件句柄,第二个参数同样为_finddata_t结构体指针。若查找成功,返回0,失败返回-1。
3、_findclose()函数:int _findclose(long);
只有一个参数,文件句柄。若关闭成功返回0,失败返回-1。
四、查找文件例子
#include <io.h>
#include <iostream>
using namespace std;
int main()
{
_finddata_t file;
int k;
long HANDLE;
k = HANDLE = _findfirst( "*.*", &file );
while( k != -1 )
{
cout << file.name << endl;
k = _findnext( HANDLE, &file );
}
_findclose( HANDLE );
return 0;
}
转自:http://blog.sina.com.cn/s/blog_67e046d10100jwdo.html
发表评论
-
c++ 读取unicode文档
2015-02-09 16:12 914int ReadOneNameFile(char *fil ... -
http://curl.haxx.se/
2013-06-13 17:41 0http://curl.haxx.se/ -
[转]线程本地存储(Thread Local Storage, TLS)分析与使用
2013-05-03 16:53 768线程本地存储(Thread Local Storage, TL ... -
C/C++获得windows版本
2012-12-01 11:05 1396MSDN上有详细介绍,做个标记: #include & ... -
[转]异常处理与MiniDump详解(4) MiniDump
2012-10-24 14:46 926异常处理与MiniDump详解(4) MiniDump wri ... -
禁用系统硬错误消息对话框
2012-08-31 19:14 688http://support.microsoft.com/kb ... -
Application Crash Dump Analysis (Windows 7)
2012-08-28 09:39 0Application Crash Dump Analysis ... -
如何成为一个windows程序debug高手
2012-08-18 14:40 0minidump: http://blog.csdn.ne ... -
Boost库编译后命名方式
2012-05-17 10:29 1280Boost官网的《Geting Started ... -
geoIP
2012-05-14 12:38 0http://www.oschina.net/code/sni ... -
vs2010 断点 无法命中
2012-05-07 16:13 1312这种情况不解决办法有 很多。你这个方法我没用过。最简单的方法就 ... -
$err,hr
2012-05-04 20:43 846在Visual C++ 中,可以在监视窗口添加 $err,hr ... -
WINDOWS下线程同步探讨
2012-04-11 15:04 918概述 线程同步可 ... -
undefined reference to 'pthread_create'问题解决
2012-03-30 11:43 0由于是Linux新手,所以现在才开始接触线程编程,照着GUN/ ... -
linux 下 遍历文件夹下的内容
2012-03-29 19:43 0// only works in cpp #ifdef __c ... -
浅谈ReadDirectoryChangesW函数的作用和问题所在
2012-03-23 10:32 4243转自:http://www.cnblogs.com ... -
我的广告
2012-03-19 10:57 0http://www.webweb.com/signup.as ... -
服务器多服务器设置
2012-03-12 18:01 720当服务器功能比较多时,可以抽象出一个代理,将不同的服务 ... -
记录个函数 strstr
2012-03-10 11:30 985包含文件:string.h 函数名: strstr 函 ... -
boost 序列化
2012-03-09 13:40 2648在用boost 二进制序列化类的时候,需要注意动态调用文件打开 ...
相关推荐
_findfirst与_findnext查找文件 一、这两个函数均在io.h里面。 二、首先了解一下一个文件结构体: struct _finddata_t { unsigned attrib; time_t time_create; time_t time_access; time_t time_wr
while SRI = 0 do begin if (SR.Name = '.') or (SR.Name = '..') then begin //不用做 end else if SR.Attr = faDirectory then begin if CheckBox1.Checked then ... SRI := FindNext(SR); end;
FindFirst 、FindNext很简单的,适合新手
C语言实现,遍历一个文件夹,并且将修改该文件夹所有文件的修改日期为最近2月。 只有一个文件,在VC下编译通过。...调用_findfirst、_findnext,纯C递归实现 大家只要修改里面的changeFiletime函数就可以自己定制功能。
Delphi操作文件的一个简单函数示例,主要是用到Win31中的DriveComboBox和DirectoryListBox两个组件及FindFirst,FindNext和FindClose三个文件操作函数。 ///////////////////////////////////////////////// ...
Delphi中使用System.SysUtils.findFirst,findnext和findclose函数进行目录遍历时,在Windows10及win11中会出现error code 18错误,在此提供一个解决方案,直接使用winapi完美解决
onedrive_find_open/onedrive_find_next, 类似 FindFirstFile和FindNext函数, onedrive_stat,类似GetFileInformationByHandle等获取文件属性的函数, onedrive_mkdir, 类似CreateDirectory创建目录函数 onedrive_...
实例CH204,在QMap中的插入、遍历和修改。 (a) for(;i.hasNext();)、qDebug()()().value():完成对QMap的遍历输出。...因此,在本例中通过查找值的函数QMutableMapIterator,T>::findNext()来实现查找和修改。
excel vba 使用findext实现快速查找
实例CH202,通过控制台程序实现QList读写遍历方法。 (a) i.insert(j):通过QMutableListIterator<T>::insert()插入操作...对于findNext()和findPrevious()有些特殊:当findNext()(或findPrevious())查找到列表项的时候
intptr_t hand = _findfirst( "E:\\source\\repos\\trace\\Debug\\*.tlog", &fileinfo; ); if( hand == -1 ) { return; } files.push_back( fileinfo.name ); while( _findnext( hand, &fileinfo; ) == 0 ) ...
一个用来查询文件的类 该类允许你使用findfirst/findnext的方法来查询你的文件系统。
if FindFirst(Path + '*', faAnyfile, sch) = 0 then begin repeat Application.ProcessMessages; if ((sch.Name = '.') or (sch.Name = '..')) then Continue; if DirectoryExists(Path + sch.Name) then ...
本文实例讲述了C++内存查找的方法,分享给大家供大家参考。...BOOL FindFirst(DWORD dwValue); BOOL FindNext(DWORD dwValue); HANDLE g_hProcess; DWORD g_arList[1024]; DWORD g_nListCnt; BOOL
if FindFirst(sDir + '*.*', faAnyFile, sr) = 0 then repeat if (sr.Name <> '.') and (sr.Name <> '..') then begin Result := False; break; end; until FindNext(sr) <> 0; FindClose(sr); end; { 是...
if FindFirst(Directory + '*.*' , faDirectory, SearchRec) = 0 then begin repeat if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] <> '.') then begin if (SearchRec.Attr...
FindFirst FindNext GetBookmark SetBookmark SetFilter SetSort GetRecordset GetActiveConnection Clone SaveAsXML OpenXML OpenSchema Requery The CADOParameter Class CADOParameter SetPrecision SetScale ...
FindFirst FindNext 卸载程序指令 WriteUninstaller 混合指令 GetErrorLevel GetInstDirError InitPluginsDir Nop SetErrorLevel SetRegView SetShellVarContext Sleep 字符串操作指令 StrCpy StrLen...
DBGridEh1.FieldColumns['fCarNum'].PickList.Add(Copy(Trim(Q.FieldByName('plate_num').AsString),4,mlen - 3)) //为了使用查找方便 else DBGridEh1.FieldColumns['fCarNum'].PickList.Add(Trim(Q.FieldByName...