调用这个函数 procedure TForm1.CreateDirTree(path: string); var SR:TSearchRec; found:integer; begin found:=FindFirst(path+'*.*',faAnyFile,SR); while found=0 do begin strtmp:=LowerCase(sr.Name); if rightstr(strtmp,4)='.txt' then begin memo1.Lines.Add(path+sr.Name); CreateDirTree(path+SR.Name+'\'); end; found:=FindNext(SR); end; FindClose(SR); end;
procedure TForm1.Button1Click(Sender: TObject); begin CreateDirTree('c:\my music\'); end; procedure TForm1.CreateDirTree(path: string); var SR:TSearchRec; found:integer; begin found:=FindFirst(path+'*.*',faAnyFile,SR); while found=0 do begin strtmp:=LowerCase(sr.Name); if rightstr(strtmp,4)='.mp3' then begin Listbox1.Items.Add(path+sr.Name); CreateDirTree(path+SR.Name+'\'); end; found:=FindNext(SR); end; FindClose(SR); end;
上面已经回答出来了, 就是用FindFirst和FindNext实现
function findfile(path:string):string; var rec:Tsearchrec; f:integer; begin //早上刚写了个子目录查找文件的程序,你就,哈哈 f:=findfirst(path+'\*.INI',rec); while f=0 do begin if rec.attr=16 then findfile(path+'\'+rec.name);//当文件为目录时递归调用 else begin ... //为文件时的处理 end; f:=findnext(rec); end; findclose(rec); end;
Undeclared identifier: 'CreateDirTree' ';' expected but '(' found Undeclared identifier: 'path' Undeclared identifier: 'rightstr' Undeclared identifier: 'Listbox1' Missing operator or semicolon Undeclared identifier: 'CreateDirTree' Undeclared identifier: 'CreateDirTree' Could not compile used unit 'Uopen.pas'错误现在还看的不是很明白。其中listbox1我已经加上去了。怎么还有这种错误呐?请指教
[Error] Uopen.pas(55): Incompatible types: 'Integer' and 'TSearchRec' 这个问题怎么解决?? 是 f:=findfirst(path+'\*.INI',rec);这段代码产生的错误....请教.....
procedure TForm1.CreateDirTree(path: string);
var
SR:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAnyFile,SR);
while found=0 do
begin
strtmp:=LowerCase(sr.Name);
if rightstr(strtmp,4)='.txt' then
begin
memo1.Lines.Add(path+sr.Name);
CreateDirTree(path+SR.Name+'\');
end;
found:=FindNext(SR);
end;
FindClose(SR);
end;
begin
CreateDirTree('c:\my music\');
end;
procedure TForm1.CreateDirTree(path: string);
var
SR:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAnyFile,SR);
while found=0 do
begin
strtmp:=LowerCase(sr.Name);
if rightstr(strtmp,4)='.mp3' then
begin
Listbox1.Items.Add(path+sr.Name);
CreateDirTree(path+SR.Name+'\');
end;
found:=FindNext(SR);
end;
FindClose(SR);
end;
就是用FindFirst和FindNext实现
var
rec:Tsearchrec;
f:integer;
begin
//早上刚写了个子目录查找文件的程序,你就,哈哈
f:=findfirst(path+'\*.INI',rec);
while f=0 do
begin
if rec.attr=16 then
findfile(path+'\'+rec.name);//当文件为目录时递归调用
else
begin
... //为文件时的处理
end;
f:=findnext(rec);
end;
findclose(rec);
end;
';' expected but '(' found
Undeclared identifier: 'path'
Undeclared identifier: 'rightstr'
Undeclared identifier: 'Listbox1'
Missing operator or semicolon
Undeclared identifier: 'CreateDirTree'
Undeclared identifier: 'CreateDirTree'
Could not compile used unit 'Uopen.pas'错误现在还看的不是很明白。其中listbox1我已经加上去了。怎么还有这种错误呐?请指教
这个问题怎么解决??
是 f:=findfirst(path+'\*.INI',rec);这段代码产生的错误....请教.....