파일1개를 비교하여 내PC에 없거나 있더라도 오래된 것일 때 ftp로 자동 다운로드 하는 것인데......
날짜비교를 하려니까 대부분 원론은 있고 실예제가 없어 아래와 같이 List와 DirectoryListing.Items[0].ModifiedDate를 사용하여 구현을 했는데......
List(tmpSList,'*.*',true)에서 전체를 읽어들이고 파일명이 '태극기.jpg'를 찾아 날짜를 어떻게 구하는 가요?
즉 몇번째인지 어떻게 찾는가요?
var
tmpSList : TStringList;
fHandle : Integer;
tmpSList := TStringList.Create;
with IdFTP1 do
begin
Host := FTP_Host;
Port := 21;
Username := FTP_Username;
Password := FTP_Password;
Connect;
ChangeDir('/map');
List(tmpSList,'태극기.jpg',true); //* 매우 중요
fHandle := FileOpen('c:\vws\map\태극기.jpg', 0);
gp_MessageInfo(formatdatetime('yyyy-mm-dd hh:nn:ss',DirectoryListing.Items[0].ModifiedDate)); //* 요것도 중요
gp_MessageInfo(formatdatetime('yyyy-mm-dd hh:nn:ss',FileDateToDateTime(FileGetDate(fHandle))));
if (not FileExists('c:\vws\map\태극기.jpg')) or (DirectoryListing.Items[0].ModifiedDate > FileGetDate(fHandle)) then
Get(tmpFile, 'c:\vws\map\태극기.jpg');
FileClose(fHandle);
Disconnect;
end;
tmpSList.Free;
FFTP.MFTP.Caption := ' FTP List 조회중...';
FFTP.MFTP.Refresh ;
try
FFTP.IdFTP.ChangeDir(FTPDIR);
except
FFTP.IdFTP.Disconnect;
FFTP.MFTP.Caption := 'Server DownLoad Path 확인하세요.';
// fn_MYes('Error',FFTP.MFTP.Caption);
// Exit;
end;
// ShowMessage( FFTP.IdFTP.RetrieveCurrentDir);
LSList := TStringList.Create;
FFTP.IdFTP.List(LSList,'*.*',True); { Unix }
for I := 0 to LSList.Count -1 do { AS/400 }
begin
if ( POS('.EXE',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.BMP',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.GIF',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.DLL',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.ZIP',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.INI',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.OCX',UpperCase(LSList.Strings[I])) <> 0 ) or
( POS('.MPG',UpperCase(LSList.Strings[I])) <> 0 ) then
begin
if not Base_Insert then
funWriteftpInI('BASE','BASE',Trim(LSList.Strings[I]));
for J := 1 to FFTP.AGFTP.RowCount do
begin
if Length(Trim(Copy(LSList.Strings[I],FTP_size_s,FTP_size_e))) = 0 then
Break;
if FFTP.AGFTP.CellS[1,J] = '' then
begin
FFTP.AGFTP.Cells[0,J] := IntToStr(J) ;
FFTP.AGFTP.Alignments[0,J] := taCenter ;
FFTP.AGFTP.Alignments[2,J] := taRightJustify ;
FFTP.AGFTP.Alignments[3,J] := taCenter ;
FFTP.AGFTP.Alignments[4,J] := taCenter ;
FFTP.AGFTP.CellS[1, J] := Trim(Copy(LSList.Strings[I],FTP_file_s,FTP_file_e));
FFTP.AGFTP.Cells[2, J] := fn_Sf(Pad_OCode(Trim(Copy(LSList.Strings[I],FTP_size_s, FTP_size_e))));
FFTP.AGFTP.CellS[3, J] := Trim(Copy(LSList.Strings[I],FTP_date_s,FTP_date_e));
FFTP.AGFTP.CellS[5, J] := FTPDIR;
if Copy(FTPDIR,Length(FFTP.AGFTP.CellS[5, J]),1) <> '/' then
FFTP.AGFTP.CellS[5, J] := FFTP.AGFTP.CellS[5, J] + '/';
FFTP.AGFTP.CellS[5, J] := FFTP.AGFTP.CellS[5, J] + FFTP.AGFTP.CellS[1, J];
Break;
end; // if
end; // for
end;
end;