C
ccniao
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure connectFtpSite(ftpSite:string;user:string;pass:string);<br>var<br>hFindointer;<br>wfd:TWin32FindData;<br>hInternet,hConnectointer;<br>begin<br>hInternet:=InternetOpen(pchar('Application'),0,nil,nil,0);<br>if hInternet=nil then begin<br>showmessage('InternetOpen error!');<br>exit;<br>end;<br>if (user='') and (pass='') then<br> hConnect:=InternetConnect(hInternet,pchar(ftpSite),INTERNET_DEFAULT_FTP_PORT,nil,nil,INTERNET_SERVICE_FTP,INTERNET_FLAG_EXISTING_CONNECT OR INTERNET_FLAG_PASSIVE,$0)<br> else<br> hConnect:=InternetConnect(hInternet,pchar(ftpSite),INTERNET_DEFAULT_FTP_PORT,pchar(user),pchar(pass),INTERNET_SERVICE_FTP,0,$0);<br><br>if hConnect=nil then begin<br>showmessage('InternetConnect error!');<br>exit;<br>end;<br><br>showmessage('connect ok!');<br><br>if FtpSetCurrentDirectory(hConnect,pchar('/a/'))=false then begin<br> showmessage('error!');<br> exit;<br> end;<br>hFind:=FtpFindFirstFile(hConnect,pchar('*.*'),wfd,0,$0);<br>if hFind=nil then<br> showmessage('error');<br><br><br>if FtpSetCurrentDirectory(hConnect,pchar('/b/'))=false then begin<br> showmessage('error!');<br> exit;<br> end;<br><br> hFind:=FtpFindFirstFile(hConnect,pchar('*.*'),wfd1,0,$0);<br>if hFind=nil then //这里出现error<br> showmessage('error');<br><br>InternetCloseHandle(hConnect);<br>InternetCloseHandle(hInternet);<br>end;<br><br>ftp服务器上根目录下有a,b两个目录,并且都有文件在里面<br>现在在标记的地方出现了 error,可见跳转目录后在用ftpFindFirstFile就不行了。<br>到底是为什么啊?这个样子的话还怎么实现遍历服务器上的文件呢?<br>