procedure TfrmMain.NMFTP1ListItem(Listing: String);
begin
//
memo1.Lines.Add(listing);
end;
Getting a directory list on a remote host:
Once you are connected to the server, you can get a listing of the files and directories there by calling the "List' method, and writing an event handler for the "OnListItem" event.
For each item listed, the OnListItem event is called.
If the ParseList property is set to TRUE, the FTPDirectoryList property will contain the elements for each listing, including name, size, and attributes.
If this command succeeds, the OnSuccess event will be called, otherwise the OnFailure event is called. In either case, cmdList is passed as the Trans_Type parameter in the event.
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
ListItem : TListItem;
begin
NMFTP.Connect;
NMFTP.ParseList := True;
NMFTP.List;
for I := 0 to (NMFTP.FTPDirectoryList.Name.Count - 1) do
begin
with NMFTP.FTPDirectoryList do
begin
ListItem := lvFileList.Items.Add;
ListItem.Caption := Name[I]; //这几行改了
ListItem.SubItems.Add(Size[I]); //
ListItem.SubItems.Add(ModifDate[I]); //
ListItem.SubItems.Add(Attribute[I]); //
end;
end;
end;