我想查找指定目录的某类型文件并加入列表,是不是用FindFirst什么的?但是看不动struct _wffblk 。。。

CPerlAsm_Lx 2003-09-15 12:51:03
我想查找指定目录的某类型文件并加入列表,是不是用FindFirst什么的?但是看不动struct _wffblk 。。。什么的,不知道怎么用?


另外,如何熟悉这些函数让自己也知道什么时候去找什么函数呢。。感觉好多东西,也没有资料看。。
...全文
128 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
tccsdn 2003-09-15
  • 打赏
  • 举报
回复
TSearchRec sc;

if( FindFirst(SongPathEdit->Text+"*.*", faAnyFile, sc )==0 )
{
do
{
if( !(sc.Attr & faDirectory ) &&
(ExtractFileExt(SongPathEdit->Text+sc.Name)==".mpg")||
(ExtractFileExt(SongPathEdit->Text+sc.Name)==".MPG")||
(ExtractFileExt(SongPathEdit->Text+sc.Name)==".dat")||
(ExtractFileExt(SongPathEdit->Text+sc.Name)==".DAT") )
{

}
}while (FindNext(sc)==0 );
FindClose(sc);
}

改动一点就可以用了
CPerlAsm_Lx 2003-09-15
  • 打赏
  • 举报
回复
我当然知道BIT,是我不小心误解bit fields的意思了。。。

netsys2 2003-09-15
  • 打赏
  • 举报
回复
你的英语还没过2级吧?

f_ftime and ff_fdate contain bit fields for referring to the current date and time.
f_ftime 和 ff_fdate包含按bit分割的时间和日期。
(你如果不知道bit,你就别编程了)

The structure of these fields was established by the operating system.
这些结构都是操作系统建立的

Both are 16-bit structures divided into three fields.

都是16bit分割的域


ff_ftime:

Bits 0 to 4 The result of seconds divided by 2 (for example 10 here means 20 seconds)

从0~4bit:秒数除2的 结果,例如,数据是10代表20秒

Bits 5 to 10 Minutes

5~10bit:分钟

Bits 11 to 15 Hours
11~15bit:小时

ff_fdate:

Bits 0-4 Day
Bits 5-8 Month
Bits 9-15 Years since 1980 (for example 9 here means 1989)
从1980年起的年数,例如数据为9,就是1980+9=1989年
weixing979 2003-09-15
  • 打赏
  • 举报
回复
AnsiString dir;
TSearchRec SearchRec;
SelectDirectory ("请选择一个文件夹","",dir); //浏览文件夹
if( FindFirst(dir+"\\*.txt",faAnyFile,SearchRec)==0) // 查找第一个txt文件
ListBox->Items->Add(dir+"\\"+SearchRec.Name);
while (FindNext(SearchRec)==0)
ListBox->Items->Add(dir+"\\"+SearchRec.Name);
FindClose(SearchRec);
在指定目录下查找txt文件,并填加到ListBox中
weixing979 2003-09-15
  • 打赏
  • 举报
回复
AnsiString dir;
TSearchRec SearchRec;
SelectDirectory ("请选择一个文件夹","",dir); //浏览文件夹
if( FindFirst(dir+"\\*.txt",faAnyFile,SearchRec)==0) // 查找第一个txt文件
ListBox->Items->Add(dir+"\\"+SearchRec.Name);
while (FindNext(SearchRec)==0)
ListBox->Items->Add(dir+"\\"+SearchRec.Name);

FindClose(SearchRec);


在指定目录上查找txt文件,并填加到listbox中
CPerlAsm_Lx 2003-09-15
  • 打赏
  • 举报
回复
netsys2(来电) 跟你去看了一趟,不过我的英语还不怎么好。加强中。。。

哟没有能稍微翻译一下的

ff_ftime and ff_fdate contain bit fields for referring to the current date and time.
bit fields ????不懂!
zihan 2003-09-15
  • 打赏
  • 举报
回复
void __fastcall TForm1::RecursionFiles(AnsiString Path)
{
TSearchRec sr;
if(FindFirst(Path+"\\*.txt",faAnyFile,sr)==0)
{
do{
FileList->Add(Path+sr.Name);
} while (FindNext(sr) == 0);
FindClose(sr);
}
}
netsys2 2003-09-15
  • 打赏
  • 举报
回复
跟我来:

CB菜单--》Help-->C++ Builder Help

输入关键词:

findfirst

选择第二项:

findfirst,_wfindfirst

出来一大篇东西,慢慢看:

Examples:

/* findfirst and findnext example */

#include <stdio.h>
#include <dir.h>

int main(void)
{
struct ffblk ffblk;
int done;
printf("Directory listing of *.*\n");
done = findfirst("*.*",&ffblk,0);
while (!done)
{
printf(" %s\n", ffblk.ff_name);
done = findnext(&ffblk);
}

return 0;
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧