国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

TListView組件顯示文件夾中的文件

2019-11-18 18:32:19
字體:
來源:轉載
供稿:網友
 

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使用--拖放操作

下一篇:使用互斥對象讓程序只運行一次

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 怀来县| 贵港市| 扶沟县| 洞口县| 阳泉市| 武山县| 苗栗市| 志丹县| 涿鹿县| 班玛县| 弥渡县| 乡城县| 咸丰县| 固安县| 黄大仙区| 新蔡县| 长子县| 海口市| 同心县| 绥棱县| 仙桃市| 阿坝县| 桂平市| 丰顺县| 库车县| 高青县| 冀州市| 瑞金市| 象州县| 郑州市| 周宁县| 安康市| 梅河口市| 乌兰县| 邮箱| 铁力市| 金湖县| 玉田县| 盱眙县| 分宜县| 卫辉市|