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
file://必须
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);
file://递归调用
ex_download(remote_dir+ss+'\',local_dir);
end;
end;
result:=true;
end
except
On E:Exception do begin
result:=false;
end;
end;
end;
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
file://必须
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);
file://递归调用
ex_download(remote_dir+ss+'\',local_dir);
end;
end;
result:=true;
end
except
On E:Exception do begin
result:=false;
end;
end;
end;
解决方案 »
- 要过节了,散点分
- dephi查询PostgreSQL数据库到表格中中文显示乱码
- 大家看看,给个思路!
- 请教关于自动运行时程序的路径问题
- ado的奇怪问题,多步操作产生错误,请检查每一步状态值
- delphi6.0+SQLServer,关于数据库出错信息的捕获
- 特急!!!各位高手能否告诉我这个报错是什么吗?Access violation at address 00404C6B in module 'Project1.exe'.Read of address 00000FAA
- 在线亟待,如何使dbgrid被选定的一行便蓝色
- 请问一个控件,点击鼠标左键,出现上弹式菜单
- 如何利用delphi将查询结果,作成网页形式??
- 如何在IE的工具栏上添加自己的按钮?十万火急,在线等待。
- 如何屏蔽flash控件的菜单?
覆盖掉同名文件?if FileExists(fn) then DeleteFile(fn)然后写新文件。
1.服务器就只是局域网内部另外一台电脑;
2.服务器上的文件目录是设定了可以读的共享权限,但是该机器没有开通FTP
之类的服务。
3.除了上面的办法之外,有没有其他的办法?请各位多多指点。多谢!
设置路径的时候如\\server\net\ddd.txt;本地复制文件实例procedure TForm1.Button1Click(Sender: TObject);
var
p : SHFILEOPSTRUCT ;
str : string;
begin
str:=GetCurrentDir();
p.pFrom :=pchar(str+'\*.*');
showmessage(p.pFrom);
p.pTo :=pchar(str+'\backup\');
showmessage(p.pTo);
p.wFunc :=FO_COPY;
p.Wnd :=Handle;
p.lpszProgressTitle:= '请等待...';
{设定操作选项}
p.fFlags:= FOF_ALLOWUNDO or FOF_NOCONFIRMMKDIR
or FOF_NOCONFIRMATION or FOF_FILESONLY ;
try
SHFileOperation(p);
except
messagedlg('备份文件出错!',mtError,[mbOk],0);
exit;
end;end;