如何检查FTP连接? [英] How to check FTP connection?
本文介绍了如何检查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.
推荐答案
您可以尝试使用
System.Net.FtpWebRequest
,然后只检查 GetResponseStream
方法。
You could try using
System.Net.FtpWebRequest
and then just check the GetResponseStream
method.
因此,像
System.Net.FtpWebRequest myFTP = new System.Net.FtpWebRequest
//Add your credentials and ports
try
{
myFTP.GetResponseStream();
//set some flags
}
catch ex
{
//handle it when it is not working
}
这篇关于如何检查FTP连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文