[C#] 纯文本查看 复制代码 using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
namespace System
{
/// <summary>
/// FTP类
/// </summary>
public class FTP
{
public bool CheckFtp(string DomainName, String port, String address, string FtpUserName, string FtpUserPwd)
{
try
{
FtpWebRequest ftprequest = (FtpWebRequest)WebRequest.Create("ftp://" + DomainName + ":" + port + "//" + address);
ftprequest.Credentials = new NetworkCredential(FtpUserName, FtpUserPwd);
ftprequest.Method = WebRequestMethods.Ftp.ListDirectory;
// ftprequest.Timeout = 3000;
FtpWebResponse ftpResponse = (FtpWebResponse)ftprequest.GetResponse();
ftpResponse.Close();
return true;
}
catch (Exception ex)
{
return false;
}
}
}
}
|