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

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827537
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜

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

          {-------------------------------------------------------------------------------
          過程名:    MakeFileList 遍歷文件夾及子文件夾
          作者:      SWGWEB
          日期:      2007.11.25
          參數:      Path,FileExt:string   1.需要遍歷的目錄 2.要遍歷的文件擴展名
          返回值:    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;

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

          字符截取函數LeftStr, MidStr, RightStr
          這幾個函數都包含在StrUtils中,所以需要uses StrUtils;
          假設字符串是 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;

          這幾個函數經常結合Pos, Length, Copy使用




          posted on 2010-05-19 11:48 Ke 閱讀(3557) 評論(0)  編輯  收藏 所屬分類: delphi
          主站蜘蛛池模板: 甘孜| 临夏市| 翁牛特旗| 靖宇县| 陇西县| 丹东市| 云安县| 特克斯县| 嵊州市| 金乡县| 陇川县| 莎车县| 太仆寺旗| 宁明县| 年辖:市辖区| 建瓯市| 四平市| 永靖县| 雷波县| 蓬莱市| 鄂托克前旗| 牙克石市| 肃北| 北海市| 宽甸| 邵阳市| 高尔夫| 文登市| 遵义县| 永吉县| 洞口县| 合阳县| 武乡县| 定远县| 资中县| 汶川县| 堆龙德庆县| 房产| 固安县| 怀来县| 军事|