TListView组件显示文件夹中的文件
来源:互联网 发布:java io流读取文件 编辑:程序博客网 时间:2024/06/05 20:23
procedure GetDirectories(list: TlistView; Directory: string; Item: Tlistitem; IncludeFiles: boolean);
var
SearchRec: TSearchRec;
begin
list.Items.BeginUpdate;//准备更新
list.Items.Clear; //清空list内容
if Directory[length(Directory)] <> '/' then //判断路径
Directory := Directory + '/'; //设置路径
if FindFirst(Directory + '*.*',faDirectory,SearchRec) = 0 then begin
repeat
if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] <> '.') then
begin
if (SearchRec.Attr and faDirectory > 0) then begin Item := list.Items.Add; //增加item
item.Caption:=SearchRec.Name;
item.ImageIndex:=6;
end;
GetDirectories(list,Directory + SearchRec.Name,Item,IncludeFiles);
end
else
if IncludeFiles then
if SearchRec.Name[1] <> '.' then
begin
item:=list.Items.Add;
item.Caption:=SearchRec.Name;
item.ImageIndex:=6;
end;
until FindNext(SearchRec) <> 0;
//FindClose(SearchRec);
end;
list.Items.EndUpdate;
end;
定义Directory:
procedure makedir(modulname,pathname,dirname,filepath:string);//创建目录(共4级,朋友如果觉得用得上的话,可以自己加参数)
begin
try
if not directoryexists(frootpath+modulname) then
createdir(FRootPath+modulname);
if not DirectoryExists(FRootPath+modulname+'/'+pathname) then
createdir(FRootPath+modulname+'/'+pathname);
if not directoryexists(FRootPath+modulname+'/'+pathname+'/'+dirname) then
createdir(FRootPath+modulname+'/'+pathname+'/'+dirname);
if filepath<>'' then
if not directoryexists(FRootPath+modulname+'/'+pathname+'/'+dirname+'/'+filepath) then
createdir(FRootPath+modulname+'/'+pathname+'/'+dirname+'/'+filepath)
except
On E:Exception do begin
abort;
end;
end;
banjin.N21.Enabled:=true;
liucheng.MenuItem1.Enabled:=true;
yanzheng.N21.Enabled:=true;
banjin.SpeedButton1.Enabled:=true;
liucheng.SpeedButton1.Enabled:=true;
yanzheng.SpeedButton1.Enabled:=true;
banjin.toolbutton1.Enabled:=true;
liucheng.toolbutton1.Enabled:=true;
yanzheng.toolbutton1.Enabled:=true;
if filepath='' then
filespath:=FRootPath+modulname+'/'+pathname+'/'+dirname+'/'+filepath else
filespath:=FRootPath+modulname+'/'+pathname+'/'+dirname+'/'+filepath+'/';
banjin.StatusBar1.Panels[0].Text:='你目前所在的位置:'+filespath;
liucheng.StatusBar1.Panels[0].Text:='你目前所在的位置:'+filespath;
yanzheng.StatusBar1.Panels[0].Text:='你目前所在的位置:'+filespath;
end;
如果是二级或一级目录的话,只要加上if filepath<>'' then
类似的判断就可以了,例如:makedir('设计规范','电子件','电路设计规范','');
注:在这里写的两个过程没有实现读取windows的图标,如果想实现这一功能的话要自己动手写了 ^_^
- TListView组件显示文件夹中的文件
- TlistView显示文件图标
- TListView组件使用方法
- delphi取得文件图标并在TListView中显示
- 关于TListView中的Data属性
- 显示文件夹中的文件名
- 一个功能增强的Delphi TListView组件
- 一个功能增强的Delphi TListView组件
- Delphi列表视图组件(TListView)详解
- delphi列表视图组件(TListView)使用方法|实例
- 一个功能增强的Delphi TListView组件
- 一个功能增强的Delphi TListView组件
- 一个功能增强的Delphi TListView组件
- DELPHI TLISTVIEW 多列显示的问题
- Delphi中用TListView显示数据库数据
- Delphi中用TListView显示数据库数据
- 枚举文件夹中的文件
- 遍历文件夹中的文件
- TListView组件使用方法
- 控件treeview的使用
- 一套日本软件开发的详细设计说明书格式(一)
- 一套日本软件开发的详细设计说明书格式(二)
- 一套日本软件开发的详细设计说明书格式(三)
- TListView组件显示文件夹中的文件
- tlistview使用--拖放操作
- Fvwm新手入门不完全手册(原创)
- 也谈多操作系统并存(Win98和WinMe)
- win2000进程虚拟内存数据搜索与修改
- 在web.config中建立数据库连接
- 关于.Net中属性的使用探讨(一)
- 关于.Net中属性的使用探讨(二)
- 使用Java在Web上实现简易干特图之一