T
Tina_wangyt
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了个遍例,想找出所有文件夹,但是到第二次调用该函数的时候,sPath := c:/projrct
node.text := projrct
在projrct的文件夹下还有一个文件夹
但是程序显示sr.Name = '.'
请那位大侠支持一把
procedure TfrmMain.displaydirectory(sPath :string;node:TTreeNode);
var
sr : TsearchRec;
CurrentNode : TTreeNode;
begin
if findfirst(sPath+'/*.*',faDirectory,sr) <> 0 then
begin
if(sr.Attr = faDirectory) then
begin
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
CurrentNode := tvTree.Items.AddChild(node,sr.Name);
displaydirectory(sPath + '/' + sr.Name,CurrentNode);
end;{if end}
end;{if end}
end;{if end}
while findNext(sr) = 0 do
begin
if sr.attr = faDirectory then
begin
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
CurrentNode := tvTree.Items.AddChild(Node,sr.Name);
displaydirectory(sPath + '/' + sr.Name,CurrentNode) ;
end else
begin
break;
end;{if end}
end;{if end}
end;{while end}
FindClose(sr);
end;
node.text := projrct
在projrct的文件夹下还有一个文件夹
但是程序显示sr.Name = '.'
请那位大侠支持一把
procedure TfrmMain.displaydirectory(sPath :string;node:TTreeNode);
var
sr : TsearchRec;
CurrentNode : TTreeNode;
begin
if findfirst(sPath+'/*.*',faDirectory,sr) <> 0 then
begin
if(sr.Attr = faDirectory) then
begin
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
CurrentNode := tvTree.Items.AddChild(node,sr.Name);
displaydirectory(sPath + '/' + sr.Name,CurrentNode);
end;{if end}
end;{if end}
end;{if end}
while findNext(sr) = 0 do
begin
if sr.attr = faDirectory then
begin
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
CurrentNode := tvTree.Items.AddChild(Node,sr.Name);
displaydirectory(sPath + '/' + sr.Name,CurrentNode) ;
end else
begin
break;
end;{if end}
end;{if end}
end;{while end}
FindClose(sr);
end;