全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3155
推到 Plurk!
推到 Facebook!

取得檔案建立日期時間

尚未結案
personmen
一般會員


發表:7
回覆:12
積分:3
註冊:2003-11-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-07 12:11:01 IP:211.23.xxx.xxx 未訂閱
請問, 要如何能取得檔案的建立日期和時間, 因為我想做一個自動更新的程式, 所以要比對二個執行檔的日期, 以新的覆蓋舊的, 若無新的就不做更新動作, 謝謝... Person Men
------
Person Men
00156
高階會員


發表:45
回覆:195
積分:112
註冊:2002-06-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-07 13:12:59 IP:61.56.xxx.xxx 未訂閱
利用FileAge函數
function FileAge(const FileName: string): Integer;
或者利用FindFirst尋找檔案時,傳回的SearchRec裡的Time及FindData屬性可以利用 我曾做過類似功能的程式在: http://mail.apol.com.tw/~frogcoco/myprog/Backup3.zip http://toget.pchome.com.tw/intro/utility_backup/14679.html 或許你可以利用
personmen
一般會員


發表:7
回覆:12
積分:3
註冊:2003-11-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-07 14:52:06 IP:211.23.xxx.xxx 未訂閱
請問FileAge的傳回值代表什麼意思? 如何才能判斷二個檔案中哪個比較新? 因為我想寫在程式碼中, 而不是另外執行其他程式... 謝謝... Person Men
------
Person Men
00156
高階會員


發表:45
回覆:195
積分:112
註冊:2002-06-01

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-03-07 18:02:22 IP:61.56.xxx.xxx 未訂閱
引言: 請問FileAge的傳回值代表什麼意思? 如何才能判斷二個檔案中哪個比較新? 因為我想寫在程式碼中, 而不是另外執行其他程式... 謝謝... Person Men
有關FileAge傳回值,以下是節錄HELP裡的資料: Description Call FileAge to obtain the OS timestamp of the file specified by FileName. The return value can be converted to a TDateTime object using the FileDateToDateTime function. The return value is -1 if the file does not exist.
00156
高階會員


發表:45
回覆:195
積分:112
註冊:2002-06-01

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-03-07 18:24:46 IP:61.56.xxx.xxx 未訂閱
引言: 如何才能判斷二個檔案中哪個比較新?
經過FileDateToDateTime轉換後較大的檔案比較新 例如
var a,b:TDateTime;    a:=FileDateToDateTime(FileAge('FILE_A.TXT'));
b:=FileDateToDateTime(FileAge('FILE_B.TXT'));    if a>b then ShowMessage('FILE_A.TXT 比較新')
else if a    如果不經過FileDateToDateTime的轉換,FileAge的傳回值會因作業系統而異,直接比較有可能會有問題:(以下節錄自FileDateToDateTime function/D6 HELP)
A timestamp is a signed 32-bit integer, used by the OS to record information such as the date and time a file was modified. The precise format of a timestamp depends on the OS. Use FileDateToDateTime to convert a timestamp to a TDateTime value.     
        
personmen
一般會員


發表:7
回覆:12
積分:3
註冊:2003-11-14

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-03-08 09:44:13 IP:211.23.xxx.xxx 未訂閱
瞭解... 感謝您... ^^... Person Men
------
Person Men
系統時間:2024-05-12 21:42:24
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!