我试图从移动文件通过ftp到B是这样的:处理一般例外在特定情况下
ftpClient.Rename(sourcePathName, targetPathName);
我想捕捉和处理时有文件要发生的所有异常移动未找到。但是Rename
会抛出值为{"file/directory not found"}
的通用异常FtpCommandException
。不幸的是,这种例外情况在其他一些情况下引发。
我不觉得比较例外的值是像一个干净的方法:
if("file/directory not found".equals(exception.value)) ...
如果你需要异常被不同的处理你不能用它自己的try/catch块分割你的命名代码出了自己的作用? – uk2k05