이렇게 했을경우에 파일이 없다는 내부에러메시지가 먼저 뜨고 다음 파일이없습니다 라는 메시지가 뜨는데 이럴땐 어떻하나요?
그리고 directorylist.items.count 이것 혹시 directorylisting.count 아닌가요?
directorylisting.count는 0으로만 잡히는데...
아래 소스 올리니 수정부탁합니다
procedure TfrmMain.displayFTP;
var
i,c:integer;
s:string;
AFile : TStringList;
begin
files.Items.clear;
folder.Items.Clear;
private
TransferrignData : Boolean;
BytesToTransfer: LongWord;
SizeToTransfer : LongWord;
function GetNameFromDirLine(Line: String; Var IsDirectory: Boolean): String;
function TF_Login.GetNameFromDirLine(Line: String; Var IsDirectory: Boolean): String;
var
i: Integer;
DosListing: Boolean;
begin
IsDirectory := Line[1] = 'd';
DosListing := False;
for i := 0 to 7 do
begin
if (i = 2) and not IsDirectory then
begin
IsDirectory := Copy(Line, 1, Pos(' ', Line) - 1) = '<DIR>';
if not IsDirectory then
begin
DosListing := Line[1] in ['0'..'9'];
end else begin
DosListing := True;
end;
end;
Delete(Line, 1, Pos(' ', Line));
while Line[1] = ' ' do
begin
Delete(Line, 1, 1);
end;
if DosListing and (i = 2) then Break;
end;
end;
procedure TF_Login.Connect_Server;
var
sPath : String;
begin
DirectoryListBox.Items.Clear;
IdFTP1.Disconnect;
with IdFTP1 do
begin
try
Panel_Msg.Caption := 'FTP Server 접속중...';
Host := '호스트명';
Username := '아이디';
Password := '암호';
IdFTP1.Connect( True );
TransferType := ftASCII;
List( DirectoryListBox.Items, '*.*', True );
except
Panel_Msg.Caption := 'FTP 서버에 접속 실패!';
Exit;
end;
end;
end;
procedure TF_Login.File_Update( sUpdateFolder, sUpdateFile : String; b_ZipFile );
var
s_FileDate, s_FileSize, s_FileName : String;
FTP_Name, FTP_Line : String;
IsDirectory, b_Transfer : Boolean;
i : Integer;
begin
s_FileName := sUpdateFile;
if not DirectoryExists( sUpdateFolder ) then
begin
ForceDirectories( sUpdateFolder );
end;
if not IdFTP1.Connected then Exit;
BytesToTransfer := 0;
for i := 0 to DirectoryListBox.Items.Count - 1 do
begin
if Pos( UpperCase( s_FileName ), UpperCase(DirectoryListBox.Items[i])) <> 0 then
begin
FTP_Line := DirectoryListBox.Items[i];
FTP_Name := GetNameFromDirLine(FTP_Line, IsDirectory);
BytesToTransfer := IdFTP1.Size(FTP_Name);
Break;
end;
end;
if BytesToTransfer > 0 then
begin
SizeToTransfer := BytesToTransfer;
end else begin
ShowMessage( '서버에 ' + s_FileName + ' File이 존재하지 않습니다!' );
Exit;
end;
except
end
예외처리 해주면 되죠.
그리고 list 받아올때 directorylist 로 받지 않나요?
directorylist.items.count 하면 갯수가 알수 있겠죠.