整了半天也没有搞出来,搜编了网络也没有找到一个解决方法:
搞到了一段代码,可是存在如下问题:
1. nmftp1.FTPDirectoryList.name.Count总是为0;
2. (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') 中的这个‘d’是指什么意思。
没有接触过这方面的东西,任务又紧,来不及细细摸索了,故请兄弟们相助,帮我调试一下这段代码或者有什么别的好办法,请指点一二,分数好说,不够尽管开口,直到破产为止!
function tftp.ex_download(remote_dir,local_dir:string):boolean;
var
i,j,count1:integer;
att,ss:string;
current_dir:string;
temp_dir:string;
begin
try begin
NMFTP1.ChangeDir(remote_dir);
current_dir:=remote_dir;
temp_dir:=copy(current_dir,2,length(current_dir));
if not DirectoryExists(local_dir) then CreateDir(local_dir);
if not directoryexists(local_dir+temp_dir) then createdir(local_dir+temp_dir);
nmftp1.ParseList:=true;
NMftp1.list;
count1:=nmftp1.FTPDirectoryList.name.Count;
for i:=0 to count1-1 do begin
NMFTP1.ChangeDir(current_dir);
nmftp1.list;
ss:=nmftp1.FTPDirectoryList.name.Strings[i];
att:=nmftp1.FTPDirectoryList.Attribute.Strings[i];
if (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') then begin
if not DirectoryExists(local_dir) then CreateDir(local_dir);
NMFTP1.Download(current_dir+ss,local_dir+temp_dir+ss);
end
else begin
if not directoryexists(local_dir+temp_dir+ss) then createdir(local_dir+temp_dir+ss);
ex_download(remote_dir+ss+'\',local_dir);
end;
end;
result:=true;
end
except
On E:Exception do begin
result:=false;
end;
end;
end;
搞到了一段代码,可是存在如下问题:
1. nmftp1.FTPDirectoryList.name.Count总是为0;
2. (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') 中的这个‘d’是指什么意思。
没有接触过这方面的东西,任务又紧,来不及细细摸索了,故请兄弟们相助,帮我调试一下这段代码或者有什么别的好办法,请指点一二,分数好说,不够尽管开口,直到破产为止!
function tftp.ex_download(remote_dir,local_dir:string):boolean;
var
i,j,count1:integer;
att,ss:string;
current_dir:string;
temp_dir:string;
begin
try begin
NMFTP1.ChangeDir(remote_dir);
current_dir:=remote_dir;
temp_dir:=copy(current_dir,2,length(current_dir));
if not DirectoryExists(local_dir) then CreateDir(local_dir);
if not directoryexists(local_dir+temp_dir) then createdir(local_dir+temp_dir);
nmftp1.ParseList:=true;
NMftp1.list;
count1:=nmftp1.FTPDirectoryList.name.Count;
for i:=0 to count1-1 do begin
NMFTP1.ChangeDir(current_dir);
nmftp1.list;
ss:=nmftp1.FTPDirectoryList.name.Strings[i];
att:=nmftp1.FTPDirectoryList.Attribute.Strings[i];
if (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') then begin
if not DirectoryExists(local_dir) then CreateDir(local_dir);
NMFTP1.Download(current_dir+ss,local_dir+temp_dir+ss);
end
else begin
if not directoryexists(local_dir+temp_dir+ss) then createdir(local_dir+temp_dir+ss);
ex_download(remote_dir+ss+'\',local_dir);
end;
end;
result:=true;
end
except
On E:Exception do begin
result:=false;
end;
end;
end;
解决方案 »
- 关于messagebox的是否框的详细用法,在线等,急,高分感谢
- 寻用Delphi使用Base64解这段编码的办法
- 我用delphi写了一个小www服务器,想支持PHP
- 在DBGrid中,Oncellclick事件里,如何确定所点击的cell 或是当前鼠标的位置?
- socket传输有大小限制么?有的话一次限制传输多少字节呢?
- 我实在不知道是怎么回事
- 我的DELPHI7安装后没有REPORT栏,是不是我买的这个版本有问题?
- sql语句中怎样删除字串中的一个字符?
- 我用delphi6 和sql 7,为什么我打开工程后再按shift+f12打开窗体,工程会马上关闭?
- 如何实现从一种颜色的渐变效果(如从深红-红-浅红),RGB()不好用,但又没有SHL()这个函数。
- 怎样才能实现向internet服务器提交和接收数据
- delphi6里那里有idftpserver?怎样做一个ftp sever程序?
var LastDay:string;
mstr:string;
begin
{Find Last files}
FFtp.FindFiles(FP_afile+'/*.*');
if FFtp.FindFilesCount>0 then
begin
LastDay:=GetFileHead(FFtp.FindFile.FileName);
FFtp.NextFindFile;
while not FFtp.FindFilesEOF do
begin
if (LastDay<GetFileHead(FFtp.FindFile.FileName)) or (lastday='') then
Lastday:=GetFileHead(FFtp.FindFile.FileName);
FFtp.NextFindFile;
end;
end else
begin
exit;
end;
if (trim(LastDay)='.') or (trim(LastDay)='..') then
exit;
FFtp.findfiles(FP_afile+'/'+LastDay+'.??');
{Get Last Files}
while not FFtp.FindFilesEOF do
begin
if (FFtp.findfile.FileName<>'.' ) and (FFtp.findfile.FileName<>'..') then
begin
FFtp.GetFile(FP_afile+'/'+FFtp.findfile.FileName,FLP_afile+'\'+FFtp.findfile.FileName);
end;
FFtp.NextFindFile;
end;
lxm5717() ,我们下面联系
[email protected]
var
i,j,FileCount:integer;
FileFolder,FileName:string;
current_dir:string;
Current_folder:string;
tmp_str,tmp_folder:string;
tmp_list:TStringList;
begin
try
tmp_list:=TStringList.Create;
IdFTP1.ChangeDir(remote_dir);
current_dir:=remote_dir;
Current_folder:=copy(current_dir,2,length(current_dir)); //文件夹名
tmp_str:=local_dir+'\'+Current_folder+'\';
while pos('\',tmp_str)<>0 do //在当前下载目录下创建同文件夹名
begin
tmp_folder:=copy(tmp_str,1,pos('\',tmp_str)-1);
if trim(tmp_folder)<>'' then
tmp_list.Add(tmp_folder);
tmp_str:=copy(tmp_str,pos('\',tmp_str)+1,MaxInt);
end;
tmp_str:=tmp_list.Strings[0];
for j:=1 to tmp_list.Count-1 do //从1开始丢掉盘符
begin
tmp_str:=tmp_str+'\'+tmp_list.Strings[i];
if not DirectoryExists(tmp_str) then
CreateDir(tmp_str);
end;
tmp_list.Clear;
IdFTP1.List(IdFTP1.ListResult); FileCount:=IdFTP1.DirectoryListing.Count; //本目录文件数目 for i:=0 to FileCount-1 do
begin //必须
IdFTP1.ChangeDir(current_dir);
IdFTP1.List(IdFTP1.ListResult); FileName:=IdFTP1.DirectoryListing.Items[i].FileName;
if pos('DIR',IdFTP1.DirectoryListing.Items[i].Text)=0 then //为文件
begin
IdFTP1.Get(FileName,local_dir+'\'+Current_folder+'\'+FileName,true);
end
else //为文件夹
begin
if not directoryexists(local_dir+'\'+Current_folder+'\'+FileName) then
createdir(local_dir+'\'+Current_folder+'\'+FileName);
//current_dir:= local_dir+'\'+Current_folder+'\'+FileName;
//递归调用
ex_download(remote_dir+'\'+FileName+'\',local_dir);
end;
end;
tmp_list.Free;
result:=true;
except
On E:Exception do
begin
result:=false;
end;
end;
end;