Renci.SshNet.Sftp.SftpFileStream.WriteByte C# (CSharp) Méthode

WriteByte() public méthode

Writes a byte to the current position in the stream and advances the position within the stream by one byte.
An I/O error occurs. The stream does not support writing, or the stream is already closed. Methods were called after the stream was closed.
public WriteByte ( byte value ) : void
value byte The byte to write to the stream.
Résultat void
        public override void WriteByte(byte value)
        {
            // Lock down the file stream while we do this.
            lock (_lock)
            {
                CheckSessionIsOpen();

                // Setup the object for writing.
                SetupWrite();

                // Flush the current buffer if it is full.
                if (_bufferPosition >= _writeBufferSize)
                {
                    using (var wait = new AutoResetEvent(false))
                    {
                        _session.RequestWrite(_handle, _serverFilePosition, _writeBuffer, 0, _bufferPosition, wait);
                        _serverFilePosition += (ulong) _bufferPosition;
                    }

                    _bufferPosition = 0;
                }

                // Write the byte into the buffer and advance the posn.
                _writeBuffer[_bufferPosition++] = value;
                ++_position;
            }
        }

Usage Example

Exemple #1
0
 public void WriteByteTest()
 {
     SftpSession session = null; // TODO: Initialize to an appropriate value
     string path = string.Empty; // TODO: Initialize to an appropriate value
     FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value
     SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value
     byte value = 0; // TODO: Initialize to an appropriate value
     target.WriteByte(value);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }