删除使用FTP远程文件夹 [英] Delete a remote folder using FTP

查看:576
本文介绍了删除使用FTP远程文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在编写Java代码以使用FTP传输和删除远程文件.基本上i''m为了进行传输/删除文件的发送的原始FTP命令(如DELE").对于例如

<预郎= Java" 的> sendLine(<跨度类= 代码串"> <跨度类=" 代码串 > DELE" +文件名); <登记/> <预郎= Java" 的> <跨度类= 代码关键字">私有 <跨度类= 代码关键字">空隙 sendLine(<跨度类= 代码sdkkeyword">串线)<跨度类= 代码关键字">引发 IOException的{ 如果(socket == null){ <跨度类=代码关键字">掷 <跨度类=代码关键字">新 IOException的(<跨度类=代码串"> <跨度类=代码串"> FTP未连接). } 尝试 { writer.write(线+ <跨度类= 代码串"> <跨度类=" 代码串 > \ r \ n" 个); writer.flush(); <跨度类= 代码关键字">如果(DEBUG){ System.out.println(" +行); } } 捕获(IOException e){ 插座= NULL; e; } }



现在我想删除整个文件夹.谁能告诉我怎样可以删除整个(非空)文件夹?是否有任何原始的FTP命令这样做呢?简直有些失望!

解决方案
快乐的世界FTP-命令 [ ^ ]

用于删除文件夹(更好地称为目录)的命令是命令rmdir".
您可能需要检查权限-但这与文件上的处理类似.


Hi,

I''m writing a java code to transfer and delete remote files using FTP. Basically i''m sending the raw FTP commands (like "DELE") for the transfer/deletion of files. For e.g

sendLine("DELE " + filename);


private void sendLine(String line) throws IOException {
  if (socket == null) {
    throw new IOException("FTP is not connected.");
  }
  try {
    writer.write(line + "\r\n");
    writer.flush();
    if (DEBUG) {
      System.out.println("> " + line);
    }
  } catch (IOException e) {
    socket = null;
    throw e;
  }
}



Now i would like to delete an entire folder. Can someone tell me how i can remove an entire (non-empty) folder? Are there any raw FTP commands to do so? Am quite desperate!

解决方案

The joyful world of FTP-Commands[^]

The command for deleting a folder (better known as directory) is "rmdir".
You might have to check for the rights - but that''s similar handled as on the files.


这篇关于删除使用FTP远程文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆