/// <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); }); }
/// <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]); }
/// <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)); }
/// <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))); }
/// <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))); }
/// <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)); }
/// <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); }
/// <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))); }