Пример #1
0
        /// <summary>
        /// Provides a stream which can be written to
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public async Task <Stream> OpenFileWriteStreamAsync(string fileName)
        {
            string filePath = WorkingDirectory.CombineAsUriWith(fileName);

            Logger?.LogDebug($"[FtpClient] Opening file read stream for {filePath}");
            var segments = filePath.Split('/')
                           .Where(x => !x.IsNullOrWhiteSpace())
                           .ToList();

            await CreateDirectoryStructureRecursively(segments.Take( segments.Count - 1 ).ToArray(), filePath.StartsWith("/"));

            return(new FtpDataStream(await OpenFileStreamAsync(filePath, FtpCommand.STOR), this, Logger));
        }