一下这段代码有问题,我是第一次接触用FTP的下载。提示说有语法错误。
procedure TForm1.Button1Click(Sender: TObject);
begin
UpLoad('\web','D:\ftpdir\');
end;procedure TForm1.UpLoad(Remote_path,Local_path:string);
var
strl1,strl2,strl3:TStringList;
sr: TSearchRec;
i,j,DirCount,FileCount:integer;
str:string;
begin
IdFTP1.ChangeDir(Remote_path);
DirCount:=0;FileCount:=0;
IdFTP1.MakeDir(Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)));
if FindFirst(Local_path + '\*.*', faDirectory, sr) = 0 then
begin
strl1:=TStringList.Create;
repeat
if (sr.Attr = faDirectory) and(sr.Name<>'.') and (sr.Name<>'..') then
begin
strl1.Add(sr.Name);
Inc(DirCount);
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
for i:=0 to DirCount-1 do
begin
UpLoad(Remote_path+'/'+Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)),Local_path+'\'+strl1.Strings[i]);//这里实现递归调用
end;
if FindFirst(Local_path + '\*.*',faAnyFile, sr )=0 then
begin
strl2:=TStringList.Create;
repeat
if (sr.Attr <> faDirectory) then
begin
strl2.Add(sr.Name);
Inc(FileCount);
end;
until FindNext(sr) <>0;
FindClose(sr);
end;
IdFTP1.ChangeDir(Remote_path+'/'+Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)));
for j:=0 to FileCount-1 do
begin
try
IdFTP1.Put(Local_path+'\'+strl2[j],IdFTP1.RetrieveCurrentDir+'/'+strl2[j]);
ListBox1.Items.Add('@_@ '+strl2[j]+'上传成功!');
except
ListBox1.Items.Add(':o '+strl2[j]+'上传失败!');
Continue;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
UpLoad('\web','D:\ftpdir\');
end;procedure TForm1.UpLoad(Remote_path,Local_path:string);
var
strl1,strl2,strl3:TStringList;
sr: TSearchRec;
i,j,DirCount,FileCount:integer;
str:string;
begin
IdFTP1.ChangeDir(Remote_path);
DirCount:=0;FileCount:=0;
IdFTP1.MakeDir(Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)));
if FindFirst(Local_path + '\*.*', faDirectory, sr) = 0 then
begin
strl1:=TStringList.Create;
repeat
if (sr.Attr = faDirectory) and(sr.Name<>'.') and (sr.Name<>'..') then
begin
strl1.Add(sr.Name);
Inc(DirCount);
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
for i:=0 to DirCount-1 do
begin
UpLoad(Remote_path+'/'+Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)),Local_path+'\'+strl1.Strings[i]);//这里实现递归调用
end;
if FindFirst(Local_path + '\*.*',faAnyFile, sr )=0 then
begin
strl2:=TStringList.Create;
repeat
if (sr.Attr <> faDirectory) then
begin
strl2.Add(sr.Name);
Inc(FileCount);
end;
until FindNext(sr) <>0;
FindClose(sr);
end;
IdFTP1.ChangeDir(Remote_path+'/'+Copy(Local_path,LastDelimiter('\',Local_path)+1,length(Local_path)));
for j:=0 to FileCount-1 do
begin
try
IdFTP1.Put(Local_path+'\'+strl2[j],IdFTP1.RetrieveCurrentDir+'/'+strl2[j]);
ListBox1.Items.Add('@_@ '+strl2[j]+'上传成功!');
except
ListBox1.Items.Add(':o '+strl2[j]+'上传失败!');
Continue;
end;
end;
end;
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EIdProtocolReplyError with message 'Syntax error in parameters or arguments.
'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
这个就是提示。
认真Debug的_____________________
http://lysoft.7u7.net