System.IO.BufferedStream.SetLength C# (CSharp) Méthode

SetLength() public méthode

public SetLength ( long value ) : void
value long
Résultat void
        public override void SetLength(long value)
        {
            if (value < 0)
                throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);

            EnsureNotClosed();
            EnsureCanSeek();
            EnsureCanWrite();

            Flush();
            _stream.SetLength(value);
        }

Usage Example

 public static void SetLength_NegativeValue()
 {
     using (MemoryStream underlying = new MemoryStream())
     using (BufferedStream stream = new BufferedStream(underlying))
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => stream.SetLength(-1));
         stream.SetLength(1);
         Assert.Equal(1, underlying.Length);
         Assert.Equal(1, stream.Length);
     }
 }
All Usage Examples Of System.IO.BufferedStream::SetLength