用FTP下载目录的代码,在我的电脑运行出错,错在哪里?(0分)

  • 主题发起人 主题发起人 amsea
  • 开始时间 开始时间
A

amsea

Unregistered / Unconfirmed
GUEST, unregistred user!
Procedure DownLoadDirectory(Dir: String; FtpSvr: TNMFTP);
Var
AttList: TStrings;
NameList: TStrings;
count: integer;
i: integer;
Att: String;
Begin
AttList := TStringList.Create;
NameList := TStringList.Create;
FtpSvr.ChangeDir('public_html');
FtpSvr.List;
AttList.Assign(FtpSvr.FTPDirectoryList.Attribute);
NameList.Assign(FtpSvr.FTPDirectoryList.name);
count := AttList.Count;
Try
mkdir(dir);
Except
End;
Chdir(dir);
If count = 0 Then
exit;

For i := 0 To count - 1 Do
Begin
Att := AttList.Strings;
If (Att[1] = '-') Then
Begin
Try
FtpSvr.Download(nameList.Strings, dir + '/' + NameList.Strings);
Except
End;
End;
If (Att[1] = 'd') Then
Begin
mkdir(NameList.strings);
Try
FtpSvr.ChangeDir(NameList.strings);
Except
End;
DownLoadDirectory(dir + '/' + NameList.Strings, FtpSvr);
chdir(dir);
Try
FtpSvr.ChangeDir('..');
Except
End;
End;
End;
End;
 
Procedure DownLoadDirectory(Dir: String; FtpSvr: TNMFTP);
Var
AttList: TStrings;
NameList: TStrings;
count: integer;
i: integer;
Att: String;
Begin
AttList := TStringList.Create;
NameList := TStringList.Create;

// FtpSvr.ChangeDir('public_html'); 这句是不需要的,我后加的,测试用的

FtpSvr.List;
AttList.Assign(FtpSvr.FTPDirectoryList.Attribute);
NameList.Assign(FtpSvr.FTPDirectoryList.name);
count := AttList.Count;
Try
mkdir(dir);
Except
End;
Chdir(dir);
If count = 0 Then
exit;

For i := 0 To count - 1 Do
Begin
Att := AttList.Strings;
If (Att[1] = '-') Then
Begin
Try
FtpSvr.Download(nameList.Strings, dir + '/' + NameList.Strings);
Except
End;
End;
If (Att[1] = 'd') Then
Begin
mkdir(NameList.strings);
Try
FtpSvr.ChangeDir(NameList.strings);
Except
End;
DownLoadDirectory(dir + '/' + NameList.Strings, FtpSvr);
chdir(dir);
Try
FtpSvr.ChangeDir('..');
Except
End;
End;
End;
End;
 
没有人知道?
 
在ftpsvr.list前面加上以下两句
ftpsvr.ParseList:=true;
ftpsvr.Vendor:=NMOS_AUTO;
 
接受答案了.
 
后退
顶部