private void Disconnect() { //Close and dispose the ftp connection _Connection.Close(); _Connection.Dispose(); _Connection = null; }
private bool _Reconnect() { try { if (_ftpSession != null) { _ftpSession.Close(); _ftpSession.Dispose(); _ftpSession = null; GC.Collect(); } _ftpSession = new FtpConnection(_host, _port, _user, _pass); _ftpSession.Open(); _ftpSession.Login(); GatLogger.Instance.AddMessage("Ftp Session {0} connected successfully"); return(true); } catch (Exception e) { if (_ftpSession != null) { _ftpSession.Close(); _ftpSession.Dispose(); _ftpSession = null; GC.Collect(); } } return(false); }
public static FtpFileInfo[] GetFiles(string path) { FtpConnection conn = GetFtpConnection(); conn.Open(); conn.Login(); FtpFileInfo[] files = conn.GetFiles(path); conn.Close(); conn.Dispose(); return(files); }
public static FtpDirectoryInfo[] GetDirectories(string path) { FtpConnection conn = GetFtpConnection(); conn.Open(); conn.Login(); FtpDirectoryInfo[] exists = conn.GetDirectories(path); conn.Close(); conn.Dispose(); return(exists); }
public static bool DirectoryExists(string path) { FtpConnection conn = GetFtpConnection(); conn.Open(); conn.Login(); bool exists = conn.DirectoryExists(path); conn.Close(); conn.Dispose(); return(exists); }
/// <summary> /// 关闭FTP /// </summary> public void CloseFTP() { ftpConnection.Dispose(); }