procedure FindFiles(Path: String);
var sr: TSearchRec;
ret: Integer;
begin
ret := FindFirst(Path + '\*.*',faAnyFile,sr);
while(ret=0) do
begin
if Pos('.',sr.Name) = 0 then
FindFiles(Path + '\' + sr.name); Form1.Memo1.Lines.Add(sr.name);
ret := findnext(sr);
end;
FindClose(sr);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FindFiles('C:\');end;
有'.'的不一定不是目录,没有'.'的不一定就是目录.
var
sr: TSearchRec;
FindRet: Integer;
begin
FindRet := FindFirst('C:\*.*',faDirectory,sr);
while FindRet = 0 do
begin
if (sr.Attr and faDirectory) <> 0 then
ListBox1.Items.Add(sr.Name);
FindRet := FindNext(sr);
end;
FindClose(sr);
end;
procedure FindFiles(Path: String;findall:boolean);
var sr: TSearchRec;
ret: Integer;
begin
ret := FindFirst(Path + '\*.*',faAnyFile,sr);
while(ret=0) do
begin
if (sr.Name <> '.') and (sr.Name <> '..') and ((SR.Attr and faDirectory) > 0) then
begin
if findall then FindFiles(Path + '\' + sr.name,findall);
Form1.Memo1.Lines.Add(sr.name);
end;
ret := findnext(sr);
end;
FindClose(sr);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FindFiles('D:\',false);//查找d:根目录下所有目录
end;procedure TForm1.Button2Click(Sender: TObject);
begin
FindFiles('D:\',true);//查找d:根目录下所有目录(包含子目录)
end;
var i: integer;
begin
with DirectoryListBox1 do
begin
Directory :='c:\';
for i:=1 to Items.count-1 do
ListBox1.Items.Add(GetItemPath(i));
end;
end;
var sr: TSearchRec;
ret: Integer;
begin
ret := FindFirst(Path + '\*.*',faAnyFile,sr);
while(ret=0) do
begin
if (sr.Name <> '.') and (sr.Name <> '..') and ((SR.Attr and faDirectory) > 0) then
begin
if findall then FindFiles(Path + '\' + sr.name,findall);
Form1.Memo1.Lines.Add(sr.name);
end;
ret := findnext(sr);
end;
FindClose(sr);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FindFiles('c:\',false);//查找d:根目录下所有目录
end;
================================================================
一颗红心向前看,为了革命两茫然,不好意思才囊尽,只能说上一点点。
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
★ 我踢 我踢 我踢 我踢 我踢 我踢 我踢 我踢 我踢 ★
★ 你UP 你UP 你UP 你UP 你UP 你UP 你UP 你UP 你UP ★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
================================================================
午休期间竟然这么热闹!>>有'.'的不一定不是目录,没有'.'的不一定就是目录.对的,自己调整吧!