Skip to content

Commit 6230d86

Browse files
committed
Added EnumerateDirectory() into ISftpClient.
1 parent 57adbee commit 6230d86

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Renci.SshNet/ISftpClient.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,28 @@ public interface ISftpClient
668668
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
669669
IEnumerable<SftpFile> ListDirectory(string path, Action<int> listCallback = null);
670670

671+
/// <summary>
672+
/// Enumerates files and directories in remote directory.
673+
/// </summary>
674+
/// <remarks>
675+
/// This method differs to <see cref="ListDirectory(string, Action{int})"/> in the way how the items are returned.
676+
/// It yields the items to the last moment for the enumerator to decide if it needs to continue or stop enumerating the items.
677+
/// It is handy in case of really huge directory contents at remote server - meaning really huge 65 thousand files and more.
678+
/// It also decrease the memory footprint and avoids LOH allocation as happen per call to <see cref="ListDirectory(string, Action{int})"/> method.
679+
/// There aren't asynchronous counterpart methods to this because enumerating should happen in your specific asynchronous block.
680+
/// </remarks>
681+
/// <param name="path">The path.</param>
682+
/// <param name="listCallback">The list callback.</param>
683+
/// <returns>
684+
/// An <see cref="System.Collections.Generic.IEnumerable{SftpFile}"/> of files and directories ready to be enumerated.
685+
/// </returns>
686+
/// <exception cref="ArgumentNullException"><paramref name="path" /> is <b>null</b>.</exception>
687+
/// <exception cref="SshConnectionException">Client is not connected.</exception>
688+
/// <exception cref="SftpPermissionDeniedException">Permission to list the contents of the directory was denied by the remote host. <para>-or-</para> A SSH command was denied by the server.</exception>
689+
/// <exception cref="SshException">A SSH error where <see cref="Exception.Message" /> is the message from the remote host.</exception>
690+
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
691+
IEnumerable<SftpFile> EnumerateDirectory(string path, Action<int> listCallback = null);
692+
671693
/// <summary>
672694
/// Opens a <see cref="SftpFileStream"/> on the specified path with read/write access.
673695
/// </summary>

0 commit comments

Comments
 (0)