隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊(cè)

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827355
          • 排名 - 49

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          copy:http://www.jackfeng.com/archives/276/

          {-------------------------------------------------------------------------------
          過(guò)程名:    MakeFileList 遍歷文件夾及子文件夾
          作者:      SWGWEB
          日期:      2007.11.25
          參數(shù):      Path,FileExt:string   1.需要遍歷的目錄 2.要遍歷的文件擴(kuò)展名
          返回值:    TStringList

             Eg:ListBox1.Items:= MakeFileList( 'E:\極品飛車','.exe') ;
                 ListBox1.Items:= MakeFileList( 'E:\極品飛車','.*') ;
          -------------------------------------------------------------------------------}
          function MakeFileList(Path,FileExt:string):TStringList ;
          var
          sch:TSearchrec;
          begin
          Result:=TStringlist.Create;

          if rightStr(trim(Path), 1) <> '\' then
              Path := trim(Path) + '\'
          else
              Path := trim(Path);

          if not DirectoryExists(Path) then
          begin
              Result.Clear;
              exit;
          end;

          if FindFirst(Path + '*', faAnyfile, sch) = 0 then
          begin
              repeat
                 Application.ProcessMessages;
                 if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
                 if DirectoryExists(Path+sch.Name) then
                 begin
                   Result.AddStrings(MakeFileList(Path+sch.Name,FileExt));
                 end
                 else
                 begin
                   if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
                   Result.Add(Path+sch.Name);
                 end;
              until FindNext(sch) <> 0;
              SysUtils.FindClose(sch);
          end;
          end;

          ------------------------------------------------------------------------------------------------------------------------------------

          字符截取函數(shù)LeftStr, MidStr, RightStr
          這幾個(gè)函數(shù)都包含在StrUtils中,所以需要uses StrUtils;
          假設(shè)字符串是 Dstr := ’Delphi is the BEST’, 那么
          LeftStr(Dstr, 5) := ’Delph’
          MidStr(Dstr, 6, 7) := ’i is th’
          RightStr(Dstr, 6) := ’e BEST’

          ~~~~~~~~~~~~~~~~~~~~~~~~~
          function RightStr
              (Const Str: String; Size: Word): String;
          begin
            if Size > Length(Str) then Size := Length(Str) ;
            RightStr := Copy(Str, Length(Str)-Size+1, Size)
          end;
          function MidStr
              (Const Str: String; From, Size: Word): String;
          begin
            MidStr := Copy(Str, From, Size)
          end;
          function LeftStr
              (Const Str: String; Size: Word): String;
          begin
            LeftStr := Copy(Str, 1, Size)
          end;

          這幾個(gè)函數(shù)經(jīng)常結(jié)合Pos, Length, Copy使用




          posted on 2010-05-19 11:48 Ke 閱讀(3557) 評(píng)論(0)  編輯  收藏 所屬分類: delphi
          主站蜘蛛池模板: 伊通| 民勤县| 三门县| 临颍县| 常熟市| 丹寨县| 祁连县| 台南市| 运城市| 西乌珠穆沁旗| 乌拉特中旗| 蓬溪县| 米易县| 任丘市| 禄劝| 陇南市| 福泉市| 青神县| 舟山市| 台南县| 凭祥市| 北宁市| 达州市| 巨鹿县| 许昌县| 华池县| 大石桥市| 青川县| 新竹县| 满洲里市| 茂名市| 班戈县| 大港区| 铁力市| 磐安县| 兴和县| 焉耆| 田阳县| 简阳市| 紫金县| 乐昌市|