ReadAllBytes() public method

Opens a binary file, reads the contents of the file into a byte array, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllBytes ( string path ) : byte[]
path string The file to open for reading.
return byte[]
        private async Task<FtpMessage> GetFromSftp(FtpConfiguration config, string path)
        {
            var host = config.FtpHost.Host;
            var username = config.Username;
            var password = config.Password;
            var port = config.FtpPort;

            using (var sftpClient = new SftpClient(host, port, username, password))
            {
                sftpClient.Connect();
                var data = sftpClient.ReadAllBytes(path);
                sftpClient.Disconnect();

                return new FtpMessage
                {
                    Configuration = config,
                    Data = data,
                    Filename = path
                };
            }
        }