2017年9月7日 星期四

搜尋目錄內的檔案名稱

var sSourcePath:String;
  iSearchRec: TSearchRec;
  iStatus: Integer;
begin
  sSourcePath := 'C:';
  iStatus := FindFirst(sSourcePath+'\*.*', faAnyFile, iSearchRec);
  try
    while iStatus = 0 do
    begin
      if ((iSearchRec.Attr and faDirectory) <> faDirectory) and //非目錄
        ((iSearchRec.Attr and faHidden)<>faHidden) and //非隱藏檔
        ((iSearchRec.Attr and faSysFile)<>faSysFile) and //非系統檔
        (iSearchRec.Name <> '.') and
        (iSearchRec.Name <> '..') then
      begin
        ...
        ...
      end;
      iStatus := FindNext(iSearchRec);
    end;
  Finally
    FindClose(iSearchRec);
  end;
end

沒有留言:

張貼留言