private void Disconnect()
 {
     //Close and dispose the ftp connection
     _Connection.Close();
     _Connection.Dispose();
     _Connection = null;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static FtpFileInfo[] GetFiles(string path)
        {
            FtpConnection conn = GetFtpConnection();

            conn.Open();
            conn.Login();
            FtpFileInfo[] files = conn.GetFiles(path);
            conn.Close();
            conn.Dispose();
            return(files);
        }
Ejemplo n.º 4
0
        public static FtpDirectoryInfo[] GetDirectories(string path)
        {
            FtpConnection conn = GetFtpConnection();

            conn.Open();
            conn.Login();
            FtpDirectoryInfo[] exists = conn.GetDirectories(path);
            conn.Close();
            conn.Dispose();
            return(exists);
        }
Ejemplo n.º 5
0
        public static bool DirectoryExists(string path)
        {
            FtpConnection conn = GetFtpConnection();

            conn.Open();
            conn.Login();
            bool exists = conn.DirectoryExists(path);

            conn.Close();
            conn.Dispose();
            return(exists);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 关闭FTP
 /// </summary>
 public void CloseFTP()
 {
     ftpConnection.Dispose();
 }