如何检查FTP连接?
是否有一种简单、快速的方法来检查 FTP 连接(包括主机、端口、用户名和密码)是否有效且正常工作?我正在使用 C#。谢谢。
Is there a simple, fast way to check that a FTP connection (includes host, port, username and password) is valid and working? I'm using C#. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试这样的事情:
try something like this:
这是我使用的方法,如果您知道更好的方法,请告诉我。
/*霍拉
这是使用最佳哈斯梅洛军刀的方法
乌比拉哈拉 100% 墨西哥
[电子邮件受保护]
*/
this is the method I use, let me know if you know a better one.
/*Hola
Este es el metodo que utilizo si conoces uno mejor hasmelo saber
Ubirajara 100% Mexicano
[email protected]
*/
这可能有用。
This might be useful.
使用 System.Net.FtpWebRequest 或 System.Net.WebRequestMethods.Ftp 来测试您的使用您的登录凭据进行连接。如果 FTP 请求由于某种原因失败,将返回相应的错误消息,指示问题所在(身份验证、无法连接等...)
Use either System.Net.FtpWebRequest or System.Net.WebRequestMethods.Ftp to test your connection using your login credentials. If the FTP request fails for whatever reason the appropriate error message will be returned indicating what the problem was (authentication, unable to connect, etc...)
你可以尝试使用
System.Net.FtpWebRequest
然后只需检查GetResponseStream
方法。所以像
You could try using
System.Net.FtpWebRequest
and then just check theGetResponseStream
method.So something like
这是来自 msdn 站点的内容,用于显示服务器上的文件
This is from the msdn site to diplay files from a server