Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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}");
            }
        }
Esempio n. 3
0
        /// <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);
            }
        }
Esempio n. 4
0
 /// <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();
     }
 }
Esempio n. 5
0
 /// <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();
     }
 }