private FtpItem BuildItem(Match match, string path) { int code; long size; FtpItem item = new FtpDirectory(); if (match.Groups["dir"].Value == "-" || match.Groups["dir"].Value == string.Empty) { item = new FtpFile(); } else { item = new FtpDirectory(); } item.FileCode = int.TryParse(match.Groups["filecode"].Value, out code) ? code : -1; item.Group = match.Groups["group"].Value; item.Host = Host; item.Name = match.Groups["name"].Value; item.Owner = match.Groups["owner"].Value; item.Path = path; item.Permissions = match.Groups["permission"].Value; item.Size = long.TryParse(match.Groups["size"].Value, out size) ? size : 0; item.Timestamp = ParseTimestamp(match); return(item); }
/// <summary> /// Gets a list of <see cref="FtpFile"/> objects from the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the files from.</param> /// <returns>A list of <see cref="FtpFile"/> from the given directory.</returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public List <FtpFile> FileList(FtpDirectory directory) { if (directory == null) { throw new ArgumentNullException("directory", "The FtpDirectory can not be null"); } return(FileList(directory.Path + directory.Name)); }
/// <summary> /// Gets a simple, string list of the sub-directories in the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the sub-directories from.</param> /// <returns>A string array of all the sub-directories of the specified <see cref="FtpDirectory"/>.</returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public string[] SimpleDirectoryList(FtpDirectory directory) { if (directory == null) { throw new ArgumentNullException("directory", "The FtpDirectory can not be null"); } return(SimpleDirectoryList(directory.Path + directory.Name)); }
/// <summary> /// Creates a new directory on the server. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to create.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public void CreateDirectory(FtpDirectory directory) { if (directory == null) { throw new ArgumentNullException("directory", "The FtpDirectory can not be null"); } CreateDirectory(directory.Path + directory.Name); }
/// <summary> /// Deletes a directory from the server. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to delete.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> /// <exception cref="UriFormatException"> /// The <paramref name="directory"/> name property is empty. /// </exception> public void DeleteDirectory(FtpDirectory directory) { if (directory == null) { throw new ArgumentNullException("directory", "The FtpDirectory can not be null"); } if (string.IsNullOrWhiteSpace(directory.Name)) { throw new UriFormatException("The FtpDirectory's Name property can not be empty"); } DeleteDirectory(directory.Path + directory.Name); }
private FtpItem BuildItem( Match match, string path ) { int code; long size; FtpItem item = new FtpDirectory(); if( match.Groups[ "dir" ].Value == "-" || match.Groups[ "dir" ].Value == string.Empty ) { item = new FtpFile(); } else { item = new FtpDirectory(); } item.FileCode = int.TryParse( match.Groups[ "filecode" ].Value, out code ) ? code : -1; item.Group = match.Groups[ "group" ].Value; item.Host = Host; item.Name = match.Groups[ "name" ].Value; item.Owner = match.Groups[ "owner" ].Value; item.Path = path; item.Permissions = match.Groups[ "permission" ].Value; item.Size = long.TryParse( match.Groups[ "size" ].Value, out size ) ? size : 0; item.Timestamp = ParseTimestamp( match ); return item; }
/// <summary> /// Gets a simple, string list of the files in the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the files from.</param> /// <returns>A string array of all the files in the specified <see cref="FtpDirectory"/>.</returns> public string[] SimpleFileList( FtpDirectory directory ) { return FileList( directory ).Select( f => f.Name ).ToArray(); }
/// <summary> /// Gets a simple, string list of the sub-directories in the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the sub-directories from.</param> /// <returns>A string array of all the sub-directories of the specified <see cref="FtpDirectory"/>.</returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public string[] SimpleDirectoryList( FtpDirectory directory ) { if( directory == null ) { throw new ArgumentNullException( "directory", "The FtpDirectory can not be null" ); } return SimpleDirectoryList( directory.Path + directory.Name ); }
/// <summary> /// Gets a list of <see cref="FtpFile"/> objects from the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the files from.</param> /// <returns>A list of <see cref="FtpFile"/> from the given directory.</returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public List<FtpFile> FileList( FtpDirectory directory ) { if( directory == null ) { throw new ArgumentNullException( "directory", "The FtpDirectory can not be null" ); } return FileList( directory.Path + directory.Name ); }
/// <summary> /// Deletes a directory from the server. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to delete.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> /// <exception cref="UriFormatException"> /// The <paramref name="directory"/> name property is empty. /// </exception> public void DeleteDirectory( FtpDirectory directory ) { if( directory == null ) { throw new ArgumentNullException( "directory", "The FtpDirectory can not be null" ); } if( string.IsNullOrWhiteSpace( directory.Name ) ) { throw new UriFormatException( "The FtpDirectory's Name property can not be empty" ); } DeleteDirectory( directory.Path + directory.Name ); }
/// <summary> /// Creates a new directory on the server. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to create.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="directory"/> argument is null. /// </exception> public void CreateDirectory( FtpDirectory directory ) { if( directory == null ) { throw new ArgumentNullException( "directory", "The FtpDirectory can not be null" ); } CreateDirectory( directory.Path + directory.Name ); }
/// <summary> /// Gets a simple, string list of the files in the given directory. /// </summary> /// <param name="directory">The <see cref="FtpDirectory"/> to get the files from.</param> /// <returns>A string array of all the files in the specified <see cref="FtpDirectory"/>.</returns> public string[] SimpleFileList(FtpDirectory directory) { return(FileList(directory).Select(f => f.Name).ToArray()); }