今天结贴,分数只给一个人!如何列出一个指定的文件夹下的所有子文件夹名。(38分)

L

lah998

Unregistered / Unconfirmed
GUEST, unregistred user!
今天结贴,分数只给一个人!如何列出一个指定的文件夹下的所有子文件夹名。

一.如何列出一个指定的文件夹下的所有子文件夹名,只列出文件夹名,不要列出
文件名(这个我有代码了)。我只要代码,能在D6中通过。

二.请帮我解释一下这段代码的意思,并要说明什么时候等于零什么情况不等于零。
if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then

注:如果没有答对我今天也一定结贴,答者有分。
 
参考:http://www.delphibbs.com/delphibbs/dispq.asp?lid=1313570

procedure TForm1.Button2Click(Sender: TObject);
var
SR:TSearchRec;
filter:TStrings;
s:string;
begin
filter:=TStringList.create;
filter.add('BMP');
filter.add('SCR');
filter.add('EXE');
if FindFirst('c:/windows/system/*.*', $3f, sr)=0 then
begin
while FindNext(sr)=0 do
begin
s:=trim(UpperCase(extractFileExt(sr.Name)));
if length(s)=0 then continue;
if s[1]='.' then s:=copy(s,2,length(s)-1);
if filter.IndexOf(s)>=0 then showmessage(sr.Name);
end;
FindClose(sr);
end;
filter.free;
end;
 

分数只给一个人,除了上面的还会有谁答你呢?[:)]
FindFirst returns 0 if a file was successfully located, otherwise, it returns an error code.
 
我的可用分是零了怎么办?我还有好多问题
 

上面的分给jsxjd,
到这里,给你一点分
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1464876
建议你问问题之前到这里找找看
http://richsearch.com/
另外,做程序员很累的,趁年轻,早点转行吧。
 
jsxjd:分数昨天我给你了,可是问题还没有解决啊!你又贴一样的过来啦,
问题可不是一样的啊!
 
procedure FindFileList(Path,Filter:string;FileList:TStrings;ContainSubDir:Boolean);
var
FSearchRec,DSearchRec:TSearchRec;
FindResult:shortint;
begin
FindResult:=FindFirst(path+Filter,sysutils.faAnyFile+faArchive-faDirectory,FSearchRec);

try
while FindResult=0 do
begin
FileList.Add(FSearchRec.Name);
FindResult:=FindNext(FSearchRec);
end;

if ContainSubDir then
begin
FindResult:=FindFirst(path+Filter,faDirectory,DSearchRec);
while FindResult=0 do
begin
if ((DSearchRec.Attr and faDirectory)=faDirectory)
and (DSearchRec.Name<>'.') and (DSearchRec.Name<>'..') then
FindFileList(Path,Filter,FileList,ContainSubDir);
FindResult:=FindNext(DSearchRec);
end;
end;
finally
FindClose(FSearchRec);
end;
end;
 


{ 功能说明:查找一个路径下的所有文件夹。
参数:path:路径, filter:文件扩展名过滤, FileList:文件列表, ContainSubDir:是否包含子目录}
procedure FindFileList(Path,Filter:string;FileList:TStrings;ContainSubDir:Boolean);
var
FSearchRec,DSearchRec:TSearchRec;
FindResult:shortint;
begin
FindResult:=FindFirst(path+Filter,faDirectory,FSearchRec);

try
while FindResult=0 do
begin
FileList.Add(FSearchRec.Name);
FindResult:=FindNext(FSearchRec);
end;

if ContainSubDir then
begin
FindResult:=FindFirst(path+Filter,faDirectory,DSearchRec);
while FindResult=0 do
begin
if ((DSearchRec.Attr and faDirectory)=faDirectory)
and (DSearchRec.Name<>'.') and (DSearchRec.Name<>'..') then
FindFileList(Path,Filter,FileList,ContainSubDir);
FindResult:=FindNext(DSearchRec);
end;
end;
finally
FindClose(FSearchRec);
end;
end;
 
影 子:你知道哪里有离线大富翁资料包下载是".chm"格式的,大好人能告诉我吗?
 
多人接受答案了。
 

下载的链接已经失效,问问别人谁有吧。
 
顶部