unit Unit1;interfaceuses
SysUtils, Classes, Controls, Forms, ComCtrls, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
TreeView1: TTreeView;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure CreateDirTree(const path:string; tnParent:TTreeNode);
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses
FileCtrl;{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
Path:string;
begin
if SelectDirectory('','',Path) then
begin
TreeView1.Items.BeginUpdate;
TreeView1.Items.Clear;
if Path[Length(Path)]<>'\' then
Path:=Path+'\';
CreateDirTree(Path,nil);
TreeView1.Items.EndUpdate;
end;
end;procedure TForm1.CreateDirTree(const path: string; tnParent: TTreeNode);
var
SR:TSearchRec;
found:integer;
node:TTreenode;
begin
found:=FindFirst(path+'*.*',faAnyFile,SR);
while found=0 do
begin
if (SR.Attr=faDirectory) and (SR.Name<>'.') and (SR.Name<>'..') then
begin
node:=TreeView1.Items.AddChild(tnParent,SR.Name);
node.Data:=Pchar(path+SR.Name);
//TreeView1.Selected:=node;
CreateDirTree(path+SR.Name+'\',node);
end;
found:=FindNext(SR);
end;
FindClose(SR);
end;end.
SysUtils, Classes, Controls, Forms, ComCtrls, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
TreeView1: TTreeView;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure CreateDirTree(const path:string; tnParent:TTreeNode);
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses
FileCtrl;{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
Path:string;
begin
if SelectDirectory('','',Path) then
begin
TreeView1.Items.BeginUpdate;
TreeView1.Items.Clear;
if Path[Length(Path)]<>'\' then
Path:=Path+'\';
CreateDirTree(Path,nil);
TreeView1.Items.EndUpdate;
end;
end;procedure TForm1.CreateDirTree(const path: string; tnParent: TTreeNode);
var
SR:TSearchRec;
found:integer;
node:TTreenode;
begin
found:=FindFirst(path+'*.*',faAnyFile,SR);
while found=0 do
begin
if (SR.Attr=faDirectory) and (SR.Name<>'.') and (SR.Name<>'..') then
begin
node:=TreeView1.Items.AddChild(tnParent,SR.Name);
node.Data:=Pchar(path+SR.Name);
//TreeView1.Selected:=node;
CreateDirTree(path+SR.Name+'\',node);
end;
found:=FindNext(SR);
end;
FindClose(SR);
end;end.
解决方案 »
- delphi只输出5个汉字怎么不行?
- 使用TF1book控件的程序在别的机器上使用要怎么部署?
- 关于使用CheckMem.pas检查内存泄漏的问题(急在线等待)
- db数据库中如何显示韩文?
- OpenDialog执行的时候出现'access violation...'
- 急!!如何让TTable一次读取多个dbf文件,并在DBGride中一次全部显示出来,最好有源码
- 有本事任性的人,也会有本事坚强
- SQL语句中的UPDATE可否这么写?
- 一个简单的问题!
- 我在SQL SERVER 2000中的一个视图上里建立了Instead of Delete触发器,为什么...请看
- 一个很简单的问题
- 初学者请教在statusbar显示鼠标移动到菜单项标题
var SearchFile:TSearchRec;
fls:Tstringlist;
stmp:string;
begin
fls:=Tstringlist.Create;
if findfirst(info.File_Filename ,faAnyFile,SearchFile)=0 then
repeat
if (SearchFile.Name='..') or (SearchFile.Name='.') then continue;
stmp:=ExtractFilePath(info.File_Filename)+SearchFile.Name;
fls.Clear;
fls.LoadFromFile(stmp);
deletefile(stmp);
submit(fls.Text,'LocalFile');
until FindNext(SearchFile) <> 0;
FindClose(SearchFile);
fls.Free;
end;
var SearchFile:TSearchRec;
fls:Tstringlist;
stmp:string;
begin
fls:=Tstringlist.Create;
if findfirst(info.File_Filename ,faAnyFile,SearchFile)=0 then
repeat
if (SearchFile.Name='..') or (SearchFile.Name='.') then continue;
stmp:=ExtractFilePath(info.File_Filename)+SearchFile.Name;
fls.Clear;
fls.LoadFromFile(stmp);
deletefile(stmp);
submit(fls.Text,'LocalFile');
until FindNext(SearchFile) <> 0;
FindClose(SearchFile);
fls.Free;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm_Main.Button5Click(Sender: TObject);
var TargetDateTime: TDateTime;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure SetDirFileTime(DirName:string);
var DirInfo: TSearchRec;
DosError: Integer;
begin
DosError := FindFirst(DirName+'\*.*', FaAnyfile, DirInfo);
while DosError=0 do
begin
if ((DirInfo.Attr and FaDirectory)=faDirectory) and (DirInfo.Name<>'.') and (DirInfo.Name<>'..')
then SetDirFileTime(DirName + '\' + DirInfo.Name);
{$IF DEFINED(WIN32) AND DECLARED(UsingVCL)}
if ((DirInfo.Attr and FaDirectory)<>FaDirectory) and ((DirInfo.Attr and FaVolumeID)<>FaVolumeID)
{$ELSE}
if ((DirInfo.Attr and FaDirectory)<>FaDirectory)
{$IFEND}
Memo.Lines.Add(DirName + '\' + DirInfo.Name);
end;
DosError := FindNext(DirInfo);
end;
SysUtils.FindClose(DirInfo);
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin
TargetDateTime := Date;
Memo.Lines.Clear;
SetDirFileTime(TargetDir);
end;