C#:FTP 如何识别 550 ftp 错误,目录已存在或目录未找到
C#:FTP 如何识别 550 ftp 错误,目录已存在或目录未找到。 因为550是可以两者兼而有之。
C# : FTP How to identify 550 ftp error ,the Directory already exists or Directory not found.
Because 550 is can be both of them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当您尝试创建目录时才会出现目录已存在的情况。因此,如果您正在创建一个目录并得到 550,那么就是这个。
找不到目录仅在浏览目录时才会发生。因此,考虑到您正在执行的操作,这很容易识别。
Directory already exists can only happen when you're trying to create a directory. So if you're creating a directory and you get a 550, then that's the one.
Directory not found can only happen while browsing to a directory. So again this is easily identifiable given what action you where doing.
简单的答案是:你不能。即使“目录已存在”仅在您尝试创建目录时发生,它仍可能因其他原因(例如缺少或无法访问父目录)返回 550。
您能做的最好的事情就是检查返回码 550,然后通过请求其文件列表来检查该目录是否已到达那里。如果它已经存在,您将得到一个列表,如果不存在,您将收到错误。
Simple answer is: you can't. Even if "directory already exists" can only happen when you are trying to create a directory, it may still return 550 for other reasons such as a missing or otherwise unaccessible parent directory.
The best you can do is to check for a return code of 550, and then check if the directory made it there by requesting its file listing. If it already exists, you'll get a listing, if not, you'll get an error.