線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2501
推到 Plurk!
推到 Facebook!

如何取目錄下檔案

答題得分者是:allenchan
nick167
中階會員


發表:86
回覆:133
積分:53
註冊:2003-02-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-10 18:24:18 IP:220.135.xxx.xxx 未訂閱
目錄是固定, 目錄下檔案是文字檔,檔名是變數(依日期 時間 流水號 丟出來) 檔名不是每分鐘丟出(不固定), 請問目錄下如何判斷有幾個files, 並可知它的檔名 我要努力,誰指點我謝謝
allenchan
資深會員


發表:10
回覆:306
積分:283
註冊:2004-01-06

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-10 18:27:24 IP:61.230.xxx.xxx 未訂閱
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TSearchRec sr;      String path = "c:\\xxx\\";
  String mask = "*.*";      int iAttributes = 0;
//  iAttributes |= faReadOnly;
//  iAttributes |= faHidden;
//  iAttributes |= faSysFile;
//  iAttributes |= faVolumeID;
//  iAttributes |= faDirectory;
  iAttributes |= faArchive;
//  iAttributes |= faAnyFile;      if (FindFirst(path   mask, iAttributes, sr) == 0)
  {
    do
    {
      if ((sr.Attr & iAttributes) == sr.Attr)
      {
        Memo1->Lines->Add(path   sr.Name);
      }
    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}
發表人 - allenchan 於 2004/12/10 18:28:32
nick167
中階會員


發表:86
回覆:133
積分:53
註冊:2003-02-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-10 19:16:22 IP:220.135.xxx.xxx 未訂閱
引言:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TSearchRec sr;      String path = "c:\\xxx\\";
  String mask = "*.*";      int iAttributes = 0;
//  iAttributes |= faReadOnly;
//  iAttributes |= faHidden;
//  iAttributes |= faSysFile;
//  iAttributes |= faVolumeID;
//  iAttributes |= faDirectory;
  iAttributes |= faArchive;
//  iAttributes |= faAnyFile;      if (FindFirst(path   mask, iAttributes, sr) == 0)
  {
    do
    {
      if ((sr.Attr & iAttributes) == sr.Attr)
      {
        Memo1->Lines->Add(path   sr.Name);
      }
    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}
發表人 - allenchan 於 2004/12/10 18:28:32
??????????????????????? 這是delphi 語法嗎 ?
allenchan
資深會員


發表:10
回覆:306
積分:283
註冊:2004-01-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-12-10 19:40:38 IP:61.230.xxx.xxx 未訂閱
哈哈,沒注意,這是 BCB 的,Delphi 請參考 http://delphi.ktop.com.tw/topic.php?topic_id=40171 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=20345    Delphi 的 Code 大概應該長下面這樣吧:
var
  sr : TSearchRec;
  path, mask : String
begin
  path = 'c:\xxx\';
  String mask = '*.*';      if FindFirst(path   mask, faArchive, sr) = 0 then
  begin
    Repeat
        Memo1->Lines->Add(path   sr.Name);
    Until FindNext(sr) <> 0;
    FindClose(sr);
  end;
end;
發表人 - allenchan 於 2004/12/10 20:17:13
nick167
中階會員


發表:86
回覆:133
積分:53
註冊:2003-02-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-12-10 20:25:33 IP:220.135.xxx.xxx 未訂閱
嗨 allenchan 我懂了, 謝謝這麼熱心 假日愉快稱心 發表人 - nick167 於 2004/12/10 20:27:30
系統時間:2024-06-24 21:02:12
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!