ftpClient.sendServer(DELE README.txt\r\n)
int reply = ftpClient.readServerResponse()
if(reply == 250){//success
System.out.println(File delete success. Filename is README.txt)}走到这里正常,reply返回值是250(有点奇怪,弄这么个你懂的数字),到这里单个文件测试正常。
接下来想要删除目录下所有文件,也就是需要取目录下列表,也就是说要用到nameList这个函数,不知道还有没有别的,我就知道这个,下面为实际想要的代码。
TelnetInputStream list = ftpClient.nameList(fullPath)
ftpClient.sendServer(DELE README.txt\r\n)
int reply = ftpClient.readServerResponse()
if(reply == 250){//success
System.out.println(File delete success. Filename is README.txt)}取完列表后再这里进行删除,下面的reply返回值始终是226,这个很奇怪,不管删除文件存在不存在,都是226,这样就午饭判断删除是否成功了。
请知道的高手帮帮忙,深表谢意!
------解决方案--------------------------------------------------------
FTP reply codes are described in RFC 959.
Generally, reply code 226 or 250 is used after a successful file transfer, after LIST commands, and after NLST commands.
Reply code 250 (but not 226) is used for a broader class of FTP commands, such as RNTO, DELE, MKD, RMD, CWD.
RFC 959 describes the command sequences where a server is allowed to reply with either reply code 226 or reply code 250.
可能是没删除成功,所以226,要删除成功的话,就会250
------解决方案--------------------------------------------------------
好吧 我接分了。
------解决方案--------------------------------------------------------
求代码看看~~~
一个人唱双簧。。。算是接分。。。
ftp -s:filename hosts >result.txt好象不是命令ftp.exe -s:"f:\del.ftp">>"f:\ftp.log"
FTP是提供批量删除功能,但是要确认才能进行.
好象没有办法解决这一问题
我都一般用手动去删除.用批量命令的时候也要确认才能进行
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)