那位大侠能帮我看一下下面一段代码有什么问题啊?(70分)

F

fosil

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是一段下载FTP上整个目录的程序,即在本地磁盘上创建FTP上某个目录下的
所以文件夹,文件下载的细节我们先不要去理会。
假设FTP的当前目录是‘/’,其下有目录‘BIN’,‘BIN’下再有‘BIN1’,‘BIN2’;
当执行download('BIN','C:/temp');时,‘BIN1'与'BIN2’可以被创建,但是
‘BIN1'与'BIN2’下的子目录就不行。
我快没分了,所以只能给70。
function TFtpForm.download(remote_dir,local_dir:string):boolean;
var
FileName:string;
lpFindFileData: TWin32FindData;
hFind: HInternet;
isDirectory:boolean;
FindResult:boolean;
begin
if not DirectoryExists(local_dir+'/'+remote_dir) then
CreateDir(local_dir+'/'+remote_dir);
FtpSetCurrentDirectory(hConnect,PChar(remote_dir));
try
begin
hFind:=FtpFindFirstFile(hConnect,'', lpFindFileData, 0, 0);
if Assigned(hFind) then
begin
FindResult:=true;
while FindResult do
begin
FileName:=string(lpFindFileData.cFilename);
if (FileName<>'.') and (FileName<>'..') then
begin
isDirectory := (lpFindFileData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY)
= FILE_ATTRIBUTE_DIRECTORY;
if isDirectory then
downLoad(FileName,local_dir+'/'+remote_dir)
else
//downloadFile(FileName,local_dir+'/'+remote_dir+'/'+FileName);
end;
FindResult:=InternetFindNextFile(hFind, @lpFindFileData);
end;
InternetCloseHandle(hFind);
result:=true;
end
else begin
showmessage('fail');
result:=false;
end;
end;
except
result:=false;
end;
FtpSetCurrentDirectory(hConnect, PChar('..'));
end;
 
初看一下没有什么问题,
跟踪一下
if not DirectoryExists(local_dir+'/'+remote_dir) then
CreateDir(local_dir+'/'+remote_dir);
^^^^^^^^^^^^^^^^^^^^^^^^
值。
 
下面的没有错误
if not DirectoryExists(local_dir+'/'+remote_dir) then
CreateDir(local_dir+'/'+remote_dir);
问题是在进入‘BIN1'与'BIN2’后
hFind:=FtpFindFirstFile(hConnect,'', lpFindFileData, 0, 0);
hFind是等于nil的,但‘BIN1'与'BIN2’是有其他文件与目录的。
 
hFind:=FtpFindFirstFile(hConnect,'', lpFindFileData, 0, 0);
请问FtpFindFirstFile是哪个单元的,应该对它的参数检验一下。
 
顶部