Renci.SshNet.Common.SshDataStream.Write C# (CSharp) Method

Write() public method

Writes a BigInteger into the SSH data stream.
public Write ( BigInteger data ) : void
data BigInteger The to write.
return void
        public void Write(BigInteger data)
        {
            var bytes = data.ToByteArray().Reverse();
            WriteBinary(bytes, 0, bytes.Length);
        }

Same methods

SshDataStream::Write ( byte data ) : void
SshDataStream::Write ( string s, Encoding encoding ) : void
SshDataStream::Write ( uint value ) : void
SshDataStream::Write ( ulong value ) : void

Usage Example

コード例 #1
0
        public void Load()
        {
            var target = new SftpAttrsResponse(_protocolVersion);
            var attributes = CreateSftpFileAttributes();
            var attributesBytes = attributes.GetBytes();

            var sshDataStream = new SshDataStream(4 + 1 + 4 + attributesBytes.Length);
            sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
            sshDataStream.WriteByte((byte) SftpMessageTypes.Attrs);
            sshDataStream.Write(_responseId);
            sshDataStream.Write(attributesBytes, 0, attributesBytes.Length);

            target.Load(sshDataStream.ToArray());

            Assert.IsNotNull(target.Attributes);
            Assert.AreEqual(_protocolVersion, target.ProtocolVersion);
            Assert.AreEqual(_responseId, target.ResponseId);
            Assert.AreEqual(SftpMessageTypes.Attrs, target.SftpMessageType);

            // check attributes in detail
            Assert.AreEqual(attributes.GroupId, target.Attributes.GroupId);
            Assert.AreEqual(attributes.LastWriteTime, target.Attributes.LastWriteTime);
            Assert.AreEqual(attributes.LastWriteTime, target.Attributes.LastWriteTime);
            Assert.AreEqual(attributes.UserId, target.Attributes.UserId);
        }
All Usage Examples Of Renci.SshNet.Common.SshDataStream::Write