MailKit.Net.Imap.ImapStream.Write C# (CSharp) Method

Write() public method

Writes a sequence of bytes to the stream and advances the current position within this stream by the number of bytes written.
Writes a sequence of bytes to the stream and advances the current position within this stream by the number of bytes written.
/// is null. /// /// is less than zero or greater than the length of . /// -or- /// The is not large enough to contain bytes strting /// at the specified . /// /// The stream has been disposed. /// /// The stream does not support writing. /// /// An I/O error occurred. ///
public Write ( byte buffer, int offset, int count ) : void
buffer byte The buffer to write.
offset int The offset of the first byte to write.
count int The number of bytes to write.
return void
		public override void Write (byte[] buffer, int offset, int count)
		{
			Write (buffer, offset, count, CancellationToken.None);
		}

Same methods

ImapStream::Write ( byte buffer, int offset, int count, CancellationToken cancellationToken ) : void

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Write the literal to the specified stream.
        /// </summary>
        /// <remarks>
        /// Writes the literal to the specified stream.
        /// </remarks>
        /// <param name="stream">The stream.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public void WriteTo(ImapStream stream, CancellationToken cancellationToken)
        {
            if (Type == ImapLiteralType.String)
            {
                var bytes = (byte[])Literal;
                stream.Write(bytes, 0, bytes.Length, cancellationToken);
                stream.Flush(cancellationToken);
                return;
            }

            if (Type == ImapLiteralType.MimeMessage)
            {
                var message = (MimeMessage)Literal;

                message.WriteTo(format, stream, cancellationToken);
                stream.Flush(cancellationToken);
                return;
            }

            var literal = (Stream)Literal;
            var buf     = new byte[4096];
            int nread;

            while ((nread = literal.Read(buf, 0, buf.Length)) > 0)
            {
                stream.Write(buf, 0, nread, cancellationToken);
            }

            stream.Flush(cancellationToken);
        }
All Usage Examples Of MailKit.Net.Imap.ImapStream::Write