5
57605993
Unregistered / Unconfirmed
GUEST, unregistred user!
如题。
代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
procedure ri(path:string;node:ttreenode);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
snode:Ttreenode;
implementation
{$R *.dfm}
procedure tform1.ri(path:string;node:ttreenode);
var
sr:Tsearchrec;
tnode:ttreenode;
begin
if findfirst(path+'/*.*',faanyfile,sr)=0 then
begin
repeat
if ((sr.Attr and fadirectory)=fadirectory)and(sr.Name[1]<>'.') then
begin
node:=treeview1.Items.AddChild(node,sr.Name);
Tnode:=node.Parent;
ri(path+sr.Name,node);
node:=tnode;
end;
until findnext(sr)<>0;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
snode:=treeview1.Items.Add(snode,'D:/');
ri('d:/',snode);
end;
end.
[red]这个程序我只遍历了文件夹,因为就这里出现问题
它只遍历到D盘下第一层子文件夹,第二层子文件夹可以看到,但文件名前面没有小加号,
就是说之后第三层第四层和之后的文件夹就没有遍历到,我确定我D盘里面文件夹不少于10层的。
不知道到底哪里出现了问题。
望高手提点! [/red]
代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
procedure ri(path:string;node:ttreenode);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
snode:Ttreenode;
implementation
{$R *.dfm}
procedure tform1.ri(path:string;node:ttreenode);
var
sr:Tsearchrec;
tnode:ttreenode;
begin
if findfirst(path+'/*.*',faanyfile,sr)=0 then
begin
repeat
if ((sr.Attr and fadirectory)=fadirectory)and(sr.Name[1]<>'.') then
begin
node:=treeview1.Items.AddChild(node,sr.Name);
Tnode:=node.Parent;
ri(path+sr.Name,node);
node:=tnode;
end;
until findnext(sr)<>0;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
snode:=treeview1.Items.Add(snode,'D:/');
ri('d:/',snode);
end;
end.
[red]这个程序我只遍历了文件夹,因为就这里出现问题
它只遍历到D盘下第一层子文件夹,第二层子文件夹可以看到,但文件名前面没有小加号,
就是说之后第三层第四层和之后的文件夹就没有遍历到,我确定我D盘里面文件夹不少于10层的。
不知道到底哪里出现了问题。
望高手提点! [/red]