public Open ( string path, FileMode mode ) : SftpFileStream | ||
path | string | The file to open. |
mode | FileMode | A |
Результат | SftpFileStream |
/// <inheritdoc /> public byte[]? DownloadFileFromServer(string basePath, string fileName) { if (String.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException(nameof(fileName)); } if (String.IsNullOrWhiteSpace(basePath)) { throw new ArgumentNullException(nameof(basePath)); } return(_retryPolicy.Execute(() => { EnsureConnected(); var filePath = GetFileFullPath(basePath, fileName); if (!_sftpClient.Exists(filePath)) { _logger.LogWarning($"File \"{filePath}\" not found on SFTP server"); return null; } using (var file = _sftpClient.Open(filePath, FileMode.Open)) { using (var ms = new MemoryStream()) { file.CopyTo(ms); return ms.ToArray(); } } })); }