删除使用FTP远程文件夹 [英] Delete a remote folder using FTP
问题描述
Hi, 这篇关于删除使用FTP远程文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
我正在编写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".
您可能需要检查权限-但这与文件上的处理类似.
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.