傳回檔案日期的疑問! |
答題得分者是:CHIWW
|
piggy213
一般會員 發表:16 回覆:6 積分:4 註冊:2002-12-27 發送簡訊給我 |
我的這一段程式目的是當按下button時,會篩選出有更新過的檔案,並複製到我指定的地方去!
可是程式跑到第13行時就出現error!!
錯誤訊息是"Invalid argument to date encode"!
請各位大師幫我看一下是哪邊出錯了!
小女子一直找不出來......
感謝各位了!! 1.procedure TForm1.Button1Click(Sender: TObject);
2.var i, T: Integer;
3. dt: TDateTime;
4. ps: TDateTime;
5. S1, M: String;
6. sDir, s2Dir, tDir: String;
7.begin
8. sDir := DirectoryListBox1.Directory '\';
9. tDir := DirectoryListBox2.Directory '\';
10. for i := 0 to FileListBox1.Items.Count - 1 do
11. begin
12. S1 := FileListBox1.Items.Strings[i];
13. dt := FileDateToDateTime(FileAge(FileListBox1.Items.Strings[i]));
14. if dt >= (Now - 1) then // 檔案時間大於前一天者
15. begin
16. s2Dir := sDir FileListBox1.Items[i];
17. tDir := DirectoryListBox2.Directory FileListBox1.Items[i];
18. Windows.CopyFile(PChar(s2Dir),PChar(tDir),false);
19. end;
20. end;
21.end;
|
chih
版主 發表:48 回覆:1186 積分:639 註冊:2002-04-02 發送簡訊給我 |
|
CHIWW
初階會員 發表:8 回覆:16 積分:29 註冊:2002-09-15 發送簡訊給我 |
//這一行
dt := FileDateToDateTime(FileAge(FileListBox1.Items.Strings[i]));
//改成
dt := FileDateToDateTime(FileAge(tDir FileListBox1.Items.Strings[i])); //這一行
tDir := DirectoryListBox2.Directory FileListBox1.Items[i];
//改成
tDir := DirectoryListBox2.Directory '\' FileListBox1.Items[i]; //我試過,這樣就可以了
|
sos_admin
版主 發表:121 回覆:697 積分:768 註冊:2003-07-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |