運行下面代碼從,出現如下錯誤
[dcc32 Error] Unit1.pas(46): E2003 Undeclared identifier: 'Text'
[dcc32 Error] Unit1.pas(48): E2003 Undeclared identifier: 'OwnerName'
[dcc32 Error] Unit1.pas(48): E2003 Undeclared identifier: 'GroupName'
[dcc32 Error] Unit1.pas(48): E2008 Incompatible types
[dcc32 Error] Unit1.pas(48): E2003 Undeclared identifier: 'LinkedItemName'
[dcc32 Error] Unit1.pas(48): E2250 There is no overloaded version of 'ShowMessage' that can be called with these arguments
[dcc32 Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
Failed
Elapsed time: 00:00:00.6
procedure TForm1.Button2Click(Sender: TObject);
var
tt :TIdFTPListItems;
t : TIdFTPListItem;
i : integer;
tfname : String;
begin //下載
Label1.Caption := IdFTP1.DirectoryListing.Items[0].FileName;
IdFTP1.TransferType := ftBinary; //指定為二進制檔案 或文本檔案ftASCII
for i:=0 to IdFTP1.DirectoryListing.Count-1 do
begin
tt := IdFTP1.DirectoryListing; //得到當前目錄下檔案及目錄串列
t := tt.Items[i]; //得到一個檔案相關資訊
Label1.Caption :=t.Text; //取出一個檔案資訊內容
tfname := t.FileName;
showmessage(t.OwnerName+' '+t.GroupName+' '+t.FileName+' '+t.LinkedItemName);
if IdFTP1.DirectoryListing.Items[i].ItemType = ditFile then //如果是檔案
begin
IdFTP1.Get(tfname,'d:\FTPtest\'+tfname,True,True); //下載到本地,并為覆寫,且支持斷點續傳
end;
end;
end;
uj5u.com熱心網友回復:
這個程式應該是用的Delphi7寫的。Delphi7的Indy版本是Indy 9,與目前絕大多數Delphi版本用的Indy10有不少區別,要作適應性修改:
procedure TForm1.Button2Click(Sender: TObject);
var
tt :TIdFTPListItems;
t : TIdFTPListItem;
i : integer;
tfname : String;
begin //下載
//Label1.Caption := IdFTP1.DirectoryListing.Items[0].FileName;
IdFTP1.TransferType := ftBinary; //指定為二進制檔案 或文本檔案ftASCII
for i:=0 to IdFTP1.DirectoryListing.Count-1 do
begin
tt := IdFTP1.DirectoryListing; //得到當前目錄下檔案及目錄串列
t := tt.Items[i]; //得到一個檔案相關資訊
// Label1.Caption :=t.Text; //取出一個檔案資訊內容
tfname := t.FileName;
// showmessage(t.OwnerName+' '+t.GroupName+' '+t.FileName+' '+t.LinkedItemName);
if IdFTP1.DirectoryListing.Items[i].ItemType = ditFile then //如果是檔案
begin
IdFTP1.Get(tfname,ExtractFilePath(Application.ExeName)+tfname,True,True); //下載到本地,并為覆寫,且支持斷點續傳
end;
end;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/276820.html
標籤:VCL組件開發及應用
上一篇:求助,c語言簡單問題