网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Delphi
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.源代码的学习(如何学习).
.Delphi程序使用资源的释放.
.术语VCL的变更:从VCL到CLX.
.(Delphi)如和下载网络文件的例子.
.用API函数在DELPHI中实现“非典型.
.模拟Nokia手机输入的编辑框.
.改良版TStringList类.
.序列化FastReport.
.抓屏技巧二三例.
.让ReportBuilder彻底支持Oracle.
.动态建表(示例).
.WANT的心得.
.在Delphi中自己建立交叉表.
.在Delphi中使用IP控件.
.Delphi随笔一.
.在打印或打印预览前如何获取报表.
.用Delphi开发DLL来代替8581协议控.
.Delphi下的OpenGL开发.
.用FASTREPORT实现WEB应用中自定义.
.Delphi中正常窗口的实现.

TListView组件显示文件夹中的文件

发表日期:2006-2-4


 

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的图标,如果想实现这一功能的话要自己动手写了 ^_^

上一篇:使用互斥对象让程序只运行一次 人气:5108
下一篇:tlistview使用--拖放操作 人气:3445
浏览全部Delphi的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐