예제 #1
0
 /// <summary>
 /// Sends RNFR / RNTO pair.
 /// </summary>
 /// <param name="ftpClient">The FTP client.</param>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 public static void RnfrTo(this FtpClient ftpClient, string from, string to)
 {
     ftpClient.Process(delegate(FtpSession session)
     {
         session.Expect(session.SendCommand("RNFR", from), 350);
         session.Expect(session.SendCommand("RNTO", to), 250);
     });
 }
예제 #2
0
        /// <summary>
        /// Sends a MLST command.
        /// </summary>
        /// <param name="ftpClient">The FTP client.</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static string Mlst(this FtpClient ftpClient, FtpPath path)
        {
            var reply = ftpClient.Process(session =>
            {
                session.CheckProtection(FtpProtection.ControlChannel);
                return(session.Expect(session.SendCommand("MLST", ftpClient.GetPlatform(session).EscapePath(path.ToString())), 250));
            });

            return(reply.Lines[1]);
        }
예제 #3
0
        /// <summary>
        /// Sends a STAT command.
        /// </summary>
        /// <param name="ftpClient">The FTP client.</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static IEnumerable <string> Stat(this FtpClient ftpClient, FtpPath path)
        {
            var reply = ftpClient.Process(session =>
            {
                session.CheckProtection(FtpProtection.ControlChannel);
                return(session.Expect(session.SendCommand("STAT", ftpClient.GetPlatform(session).EscapePath(path.ToString())), 213, 211));
            });

            return(reply.Lines.Skip(1).Take(reply.Lines.Length - 2));
        }
예제 #4
0
 /// <summary>
 /// Sends LIST command.
 /// </summary>
 /// <param name="ftpClient">The FTP client.</param>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 public static IList <string> List(this FtpClient ftpClient, FtpPath path)
 {
     return(ftpClient.Process(handle => ProcessList(handle, path)));
 }
예제 #5
0
 /// <summary>
 /// Gets a <see cref="FtpEntry" /> about given path.
 /// </summary>
 /// <param name="ftpClient">The FTP client.</param>
 /// <param name="path">The path.</param>
 /// <returns>
 /// The entry, or null if entry does not exist
 /// </returns>
 public static FtpEntry GetEntry(this FtpClient ftpClient, FtpPath path)
 {
     return(ftpClient.Process(handle => ProcessGetEntry(handle, path)));
 }
예제 #6
0
 /// <summary>
 /// Sends a MKD command (MaKe Directory).
 /// </summary>
 /// <param name="ftpClient">The FTP client.</param>
 /// <param name="path">The path.</param>
 public static void Mkd(this FtpClient ftpClient, FtpPath path)
 {
     ftpClient.Process(session => session.Expect(session.SendCommand("MKD", path.ToString()), 257));
 }
예제 #7
0
        /// <summary>
        /// Sends a DELE command (DELEte file).
        /// </summary>
        /// <param name="ftpClient">The FTP client.</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static bool Dele(this FtpClient ftpClient, FtpPath path)
        {
            var reply = ftpClient.Process(session => session.Expect(session.SendCommand("DELE", path.ToString()), 250, 550));

            return(reply.Code.IsSuccess);
        }
예제 #8
0
 /// <summary>
 /// Send STOR command.
 /// </summary>
 /// <param name="ftpClient">The FTP client.</param>
 /// <param name="path">The path.</param>
 /// <param name="mode">The mode.</param>
 /// <returns></returns>
 public static Stream Stor(this FtpClient ftpClient, FtpPath path, FtpTransferMode mode = FtpTransferMode.Binary)
 {
     return(ftpClient.Process(handle => ProcessStor(handle, path, mode)));
 }