如何检查 FTP 连接? [英] How to check FTP connection?

查看:24
本文介绍了如何检查 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.

推荐答案

试试这样的:

FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp.google.com");
requestDir.Credentials = new NetworkCredential("username", "password");
try
{
     WebResponse response = requestDir.GetResponse();
     //set your flag
}
catch
{
}

这篇关于如何检查 FTP 连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆