/// <summary> /// Closes the write stream and associated socket (if open), /// </summary> /// <param name="ctsToken"></param> /// <returns></returns> public async Task CloseFileDataStreamAsync(CancellationToken ctsToken = default(CancellationToken)) { Logger?.LogDebug("[FtpClient] Closing write file stream"); dataStream.Dispose(); await ControlStream.GetResponseAsync(ctsToken); }
/// <summary> /// Ignore any stale data we may have waiting on the stream /// </summary> /// <returns></returns> private async Task IgnoreStaleData() { if (IsConnected && ControlStream.SocketDataAvailable()) { var staleData = await ControlStream.GetResponseAsync(); Logger?.LogWarning($"Stale data detected: {staleData.ResponseMessage}"); } }
/// <summary> /// Closes the write stream and associated socket (if open), /// </summary> /// <param name="ctsToken"></param> /// <returns></returns> public async Task CloseFileDataStreamAsync(CancellationToken ctsToken = default(CancellationToken)) { Logger?.LogTrace("[FTPClient] Closing write file stream"); dataStream.Dispose(); if (ControlStream != null) { await ControlStream.GetResponseAsync(ctsToken); } }
/// <summary> /// Lists all directories in the current working directory /// </summary> /// <returns></returns> public async Task <ReadOnlyCollection <FtpNodeInformation> > ListDirectoriesAsync() { try { EnsureLoggedIn(); Logger?.LogDebug($"[FtpClient] Listing directories in {WorkingDirectory}"); return(await directoryProvider.ListDirectoriesAsync()); } finally { await ControlStream.GetResponseAsync(); } }
/// <summary> /// Lists all files in the current working directory /// </summary> /// <returns></returns> public async Task <IEnumerable <FtpNodeInformation> > ListFilesAsync() { try { EnsureLoggedIn(); LoggerHelper.Debug($"[FtpClient] Listing files in {WorkingDirectory}"); return(await directoryProvider.ListFilesAsync()); } finally { await ControlStream.GetResponseAsync(); } }