日期:2014-05-17 浏览次数:20897 次
class RequstFTP
{
string ftpServerIP;
string ftpUserID;
string ftpPassword;
FtpWebRequest reqFTP;
public void Connecttest(string ftpServerIP, string ftpUserID, string ftpPassword)
{
// 根据uri创建FtpWebRequest对象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP));
// 指定数据传输类型
reqFTP.UseBinary = false;
// ftp用户名和密码
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}
#region 连接
/// <summary>
/// 连接
/// </summary>
/// <param name="path"></param>
private void Connect(String path)//连接ftp
{
// 根据uri创建FtpWebRequest对象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
// 指定数据传输类型
reqFTP.UseBinary = false;
//使用主动(port)模式
reqFTP.UsePassive = false;
// ftp用户名和密码
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}
#endregion
#region ftp登录信息
/// <summary>
/// ftp登录信息
/// </summary>
/// <param name="ftpServerIP">ftpServerIP</param>
/// <param name="ftpUserID">ftpUserID</param>
/// <param name="ftpPassword">ftpPassword</param>
public void FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword)
&n