Exemplo n.º 1
0
        /// <summary>
        /// Construct an FTP client to connect to the given remote.
        /// </summary>
        /// <param name="remote"></param>
        public FTPClient(String remote)
        {
            try
            {
                cmdCon  = new FTPConnection(remote);
                dataCon = null;
                IsOpen  = true;
                IsDebug = false;
                CliMode = ClientMode.Passive;
                DatMode = DataMode.Binary;

                ServerMessage initialMsg = cmdCon.ReadMessage();
                HandleReply(initialMsg);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                IsOpen = false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Quit from the server and end the connection.
 /// </summary>
 /// <returns>A server message in response to this action.</returns>
 private ServerMessage Quit()
 {
     try
     {
         SendCmd("QUIT");
         ServerMessage reply = cmdCon.ReadMessage();
         IsOpen = false;
         //Send QUIT
         cmdCon.Close();
         return(reply);
     }
     catch (Exception e)
     {
         Console.WriteLine("The connection has been closed.");
         IsOpen = false;
         return(new ServerMessage());
     }
 }