C#:FTP 如何识别 550 ftp 错误,目录已存在或目录未找到

发布于 2024-10-15 03:00:18 字数 58 浏览 15 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诺曦 2024-10-22 03:00:18

仅当您尝试创建目录时才会出现目录已存在的情况。因此,如果您正在创建一个目录并得到 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.

少跟Wǒ拽 2024-10-22 03:00:18

简单的答案是:你不能。即使“目录已存在”仅在您尝试创建目录时发生,它仍可能因其他原因(例如缺少或无法访问父目录)返回 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文