• NeonSDK
  • NeonKUBE
Search Results for

    Show / Hide Table of Contents
    • Neon
      • Build
    • Neon.Blazor
      • BlazorHelper
      • BodyOutlet
      • ClientRenderContext
      • DOMRectReadOnly
      • EventHandlers
      • FileDownloader
      • HtmlElement
      • IRenderContext
      • IntersectionChangedEventArgs
      • IntersectionObserver
      • IntersectionObserverContext
      • MobileDetector
      • NeonBlazorExtensions
      • ServerRenderContext
      • SwipeDirection
      • SwipeHandler
    • Neon.Blazor.Analyzers
      • SvgGenerator
      • SvgGenerator.Svg
    • Neon.BuildInfo
      • ThisAssembly
      • ThisAssembly.Git
      • ThisAssembly.Git.BaseVersion
      • ThisAssembly.Git.SemVer
    • Neon.CSharp
      • CSharpHelper
      • CompilerErrorException
      • MetadataReferences
    • Neon.Cassandra
      • KeyspaceStatus
      • RowSetExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
      • SessionExtensions
    • Neon.Collections
      • ArgDictionary
      • Bits
      • IObjectDictionary
      • NiceDictionary<TKey, TValue>
      • ObjectDictionary
    • Neon.Common
      • AppDomainExtensions
      • Block
      • BlockArray
      • ByteEncoding
      • ByteUnits
      • CommandLine
      • CommandLine.OptionDefinition
      • CommandLine.Redactor
      • CpuArchitecture
      • Credentials
      • DateTimeExtensions
      • EnumExtensions
      • EnvironmentParser
      • EnvironmentParser.Parser<T>
      • EnvironmentParser.Validator<T>
      • EnvironmentParser.VariableSource
      • ExceptionExtensions
      • ExecuteException
      • ExecuteResponse
      • GlobPattern
      • HexDumpOption
      • HttpClientExtensions
      • HttpResponseMessageExtensions
      • IEnumerableExtensions
      • ILabeled
      • IOExtensions
      • IServiceContainer
      • IStaticDirectoryExtensions
      • LabelSelector
      • LabelSelectorOptions
      • LabelSelector<TItem>
      • NeonAssemblyExtensions
      • NeonExtendedHelper
      • NeonHelper
      • NetFramework
      • NewtonsoftExtensions
      • NotReadyException
      • ProcessExtensions
      • ProgramEntrypoint
      • ProgramEntrypointAsync
      • ProgramExitException
      • ProgramRunner
      • RandomExtensions
      • ReflectionExtensions
      • SemanticVersion
      • ServiceContainer
      • StaticZipOptions
      • StringBuilderExtensions
      • StringExtensions
      • Stub
      • Stub.Value
      • TaskExtensions
      • TimeSpanExtensions
      • ToolException
      • TriState
      • WeakEventController
      • WindowsEdition
      • WindowsFeatureStatus
      • YamlDotNetExtensions
    • Neon.Cryptography
      • AesCipher
      • CryptoExtensions
      • CryptoHelper
      • NeonVault
      • Wildcard
    • Neon.Csv
      • CsvReader
      • CsvTableReader
      • CsvTableWriter
      • CsvWriter
    • Neon.Data
      • DateTimeJsonConverter
      • DateTimeOffsetJsonConverter
      • IEnhancedJsonConverter
      • IGeneratedServiceClient
      • IPersistableType
      • IPersistableType<T>
      • IRoundtripData
      • IntegerEnumConverter<TEnum>
      • NotifyPropertyChanged
      • RoundtripDataFactory
      • RoundtripDataHelper
      • TimeSpanJsonConverter
      • VersionJsonConverter
    • Neon.Deployment
      • AwsCli
      • DeploymentException
      • DeploymentHelper
      • DownloadManifest
      • DownloadPart
      • DownloadProgressDelegate
      • DownloadProgressType
      • GitHub
      • GitHubActionsApi
      • GitHubPackage
      • GitHubPackageApi
      • GitHubPackageType
      • GitHubPackageVersion
      • GitHubPackageVisibility
      • GitHubReleaseApi
      • GitHubRepoPath
      • GitHubTagApi
      • IProfileClient
      • IProfileRequest
      • IProfileResponse
      • MaintainerProfile
      • NotifyClient
      • OnePassword
      • OnePasswordException
      • ProfileException
      • ProfileHandlerResult
      • ProfileRequest
      • ProfileResponse
      • ProfileServer
      • ProfileStatus
      • XenServer
    • Neon.Deployment.CodeSigning
      • AzureProfile
      • CodeSigner
      • UsbTokenProfile
    • Neon.Diagnostics
      • AssertException
      • ConfigExtensions
      • ConsoleJsonLogExporter
      • ConsoleJsonLogExporterOptions
      • ConsoleTextLogExporter
      • ConsoleTextLogExporterOptions
      • ExceptionInfo
      • FileLogExporter
      • FileLogExporterFormat
      • FileLogExporterOptions
      • LogAsTraceProcessor
      • LogAsTraceProcessorOptions
      • LogAttributeNames
      • LogAttributes
      • LogEvent
      • LogEventInterceptor
      • LoggerExtensions
      • NullLogger
      • TelemetryHub
      • TelemetrySpanEventNames
      • TelemetrySpanExtensions
    • Neon.Docker
      • DockerClient
      • DockerNetwork
      • DockerNetworkContainer
      • DockerNetworkIpam
      • DockerNode
      • DockerNodeManagerStatus
      • DockerResponse
      • DockerSettings
      • DockerVolume
      • NetworkCreateResponse
      • ServiceBindOptions
      • ServiceConfig
      • ServiceContainerSpec
      • ServiceCredentialSpec
      • ServiceDetails
      • ServiceDiscreteResourceSpec
      • ServiceDnsConfig
      • ServiceEndpoint
      • ServiceEndpointMode
      • ServiceEndpointPortConfig
      • ServiceEndpointSpec
      • ServiceFile
      • ServiceGenericResources
      • ServiceGlobalSchedulingMode
      • ServiceHealthCheck
      • ServiceIsolationMode
      • ServiceListResponse
      • ServiceLogDriver
      • ServiceMode
      • ServiceMount
      • ServiceMountBindPropagation
      • ServiceMountConsistency
      • ServiceMountType
      • ServiceNamedResourceSpec
      • ServiceNetwork
      • ServicePlacement
      • ServicePlacementPreferences
      • ServicePlacementSpreadSettings
      • ServicePlatform
      • ServicePortMode
      • ServicePortProtocol
      • ServicePrivileges
      • ServiceReplicatedSchedulingMode
      • ServiceResourceSettings
      • ServiceResources
      • ServiceRestartCondition
      • ServiceRestartPolicy
      • ServiceRollbackConfig
      • ServiceRollbackFailureAction
      • ServiceRollbackOrder
      • ServiceSELinuxContext
      • ServiceSchedulingMode
      • ServiceSecret
      • ServiceSpec
      • ServiceTaskTemplate
      • ServiceTmpfsOptions
      • ServiceUpdateConfig
      • ServiceUpdateFailureAction
      • ServiceUpdateOrder
      • ServiceUpdateState
      • ServiceUpdateStatus
      • ServiceVersion
      • ServiceVirtualIP
      • ServiceVolumeDriverConfig
      • ServiceVolumeOptions
      • VolumeListResponse
    • Neon.GitHub
      • GitExtensions
      • GitHubCredentials
      • GitHubRepo
      • LocalRepoApi
      • NoLocalRepositoryException
      • RemoteRepoApi
      • RemoteRepoBranchApi
      • RemoteRepoIssueApi
      • RemoteRepoIssueCommentApi
      • RemoteRepoPath
      • RemoteRepoReleaseApi
      • RemoteRepoTagApi
    • Neon.HyperV
      • HyperVClient
      • HyperVDriverType
      • HyperVException
      • NetAdapter
      • VirtualDrive
      • VirtualIPAddress
      • VirtualMachine
      • VirtualMachineNetworkAdapter
      • VirtualMachineState
      • VirtualNat
      • VirtualSwitch
      • VirtualSwitchType
    • Neon.IO
      • BlockStream
      • FixedLengthStream
      • IStaticDirectory
      • IStaticFile
      • LineEnding
      • LinuxPath
      • LinuxPermissions
      • PreprocessReader
      • RelayStream
      • StaticDirectoryBase
      • StaticFileBase
      • SubStream
      • TempFile
      • TempFolder
    • Neon.JsonConverters
      • JsonDateTimeConverter
      • JsonGenericConverter<T>
      • JsonNullableDateTimeConverter
    • Neon.ModelGen
      • ActionResult<T>
      • ApiVersion
      • ApiVersionAttribute
      • BodyStreamAttribute
      • ControllerValidationAttribute
      • DataModelAttribute
      • EnumMember
      • FromBodyAttribute
      • FromHeaderAttribute
      • FromQueryAttribute
      • FromRouteAttribute
      • GeneratedClientAttribute
      • GeneratedMethodAttribute
      • GeneratedParamAttribute
      • HashSourceAttribute
      • HttpAttribute
      • HttpDeleteAttribute
      • HttpGetAttribute
      • HttpHeadAttribute
      • HttpOptionsAttribute
      • HttpPatchAttribute
      • HttpPostAttribute
      • HttpPutAttribute
      • IActionResult
      • ModelGenerator
      • ModelGeneratorOutput
      • ModelGeneratorSettings
      • NoCodeGenAttribute
      • NoControllerValidationAttribute
      • PassAs
      • PersistableAttribute
      • PersistableKeyAttribute
      • RouteAttribute
      • ServiceModelAttribute
      • TargetAttribute
      • UxFrameworks
    • Neon.Net
      • HttpApiException
      • HttpException
      • JsonClient
      • JsonClientPayload
      • JsonResponse
      • Jwt
      • LocalHostSection
      • NetConst
      • NetHelper
      • NetworkCidr
      • NetworkConfiguration
      • NetworkException
      • NetworkPorts
      • Pinger
      • ReachableHost
      • ReachableHostMode
      • StreamDocument
    • Neon.Postgres
      • ConnectionExtensions
      • DatabaseStatus
      • PreparedCommand
      • ReaderAsyncEnumerator
      • ReaderEnumerator
      • ReaderExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
    • Neon.Retry
      • ExponentialRetryPolicy
      • IRetryPolicy
      • LinearRetryPolicy
      • NoRetryPolicy
      • RetryPolicy
      • RetryPolicyBase
      • RetryTransientArgs
      • TransientDetector
      • TransientException
    • Neon.Roslyn
      • DisplayFormat
      • DocumentationComment
      • DocumentationItem
      • MetadataLoadContext
      • RoslynAssembly
      • RoslynConstructorInfo
      • RoslynCustomAttributeData
      • RoslynExtensions
      • RoslynFieldInfo
      • RoslynMethodInfo
      • RoslynParameterInfo
      • RoslynPropertyInfo
      • RoslynType
      • SharedUtilities
    • Neon.Roslyn.Xunit
      • AdditionalSourceText
      • CompilationOptions
      • CompilationOptionsProvider
      • TestCompilation
      • TestCompilationAssertions
      • TestCompilationBuilder
      • TestCompilationBuilderExtensions
      • TestCompilationExtensions
    • Neon.SSH
      • CommandBundle
      • CommandFile
      • CommandResponse
      • HostFolders
      • IBashCommandFormatter
      • ILinuxSshProxy
      • LinuxDiskInfo
      • LinuxDiskPartition
      • LinuxSshProxy
      • LinuxSshProxy<TMetadata>
      • NamespaceDoc
      • RemoteCommandException
      • RunOptions
      • SshCredentials
      • SshExtensions
      • SshProxyException
    • Neon.Service
      • LogMetricsProcessor
      • MetricsMode
      • MetricsOptions
      • NeonService
      • NeonServiceOptions
      • NeonServiceStatus
      • OtelConfigExtensions
      • OtlpCollectorChecker
      • ProcessTerminator
      • ServiceApiContact
      • ServiceApiInfo
      • ServiceApiLicense
      • ServiceDependencies
      • ServiceDescription
      • ServiceEndpoint
      • ServiceEndpointProtocol
      • ServiceEndpoints
      • ServiceMap
    • Neon.SignalR
      • DependencyInjectionExtensions
      • DnsCache
      • GroupAction
      • GroupCommand
      • IDnsCache
      • Invocation
      • NatsHubLifetimeManager<THub>
      • ProxyConfig
      • ServiceCollectionExtensions
      • ServiceDiscovey
      • SignalrProxyMiddleware
      • SignalrProxyMiddlewareExtensions
      • TracerProviderBuilderExtensions
    • Neon.Tailwind
      • ClickOffEventHandler
      • ComponentEventArgs<TSender>
      • ComponentEventArgs<TSender, TEventArgs>
      • DisclosureState
      • EventHandlerComponentBase<TComponent>
      • HeadlessButton
      • HeadlessDialog
      • HeadlessDialogPanel
      • HeadlessDisclosure
      • HeadlessDisclosureButton
      • HeadlessDisclosurePanel
      • HeadlessListboxButton<TValue>
      • HeadlessListboxLabel<TValue>
      • HeadlessListboxOption<TValue>
      • HeadlessListboxOptions<TValue>
      • HeadlessListbox<TValue>
      • HeadlessMenu
      • HeadlessMenuButton
      • HeadlessMenuItem
      • HeadlessMenuItems
      • HeadlessSwitch
      • HeadlessSwitchGroup
      • HeadlessSwitchLabel
      • IPortalBinder
      • KeyDownEventHandler
      • KeyboardKey
      • ListboxFocus
      • ListboxState
      • MenuFocus
      • MenuState
      • Portal
      • PortalBinder
      • PortalContent
      • SearchAssistant
      • TailwindExtensions
      • Transition
      • TransitionGroup
      • TransitionState
    • Neon.Tasks
      • Async
      • AsyncAutoResetEvent
      • AsyncManualResetEvent
      • AsyncMutex
      • AsyncPeriodicTask
      • AsyncReaderWriterLock
      • AsyncReentrantMutex
      • AsyncTimer
      • IAsyncFuture
      • IAsyncFuture<T>
      • NonDisposableTask
      • NonDisposableTask<T>
      • SyncContext
      • SyncContextMode
    • Neon.Temporal
      • ActivityHelper
      • ActivityLogEnricher
      • TemporalEnricherTagNames
      • WorkflowLogEnricher
    • Neon.Time
      • GatedTimer
      • GoDuration
      • PolledTimer
      • RecurringTimer
      • RecurringTimerType
      • SysTime
      • TimeOfDay
    • Neon.WSL
      • Wsl2Proxy
    • Neon.Web
      • AesProtector
      • DataProtectionExtensions
      • NeonController
      • NeonControllerBase
      • RoundTripJsonInputFormatter
      • RoundTripJsonOutputFormatter
      • TracerProviderBuilderExtensions
      • WebHelper
    • Neon.WinTTY
      • ConsoleTTY
    • Neon.Windows
      • MEMORYSTATUSEX
      • PowerShellException
      • Win32
    • Neon.XenServer
      • IXenClient
      • XenClient
      • XenClient.MachineOperations
      • XenClient.StorageOperations
      • XenClient.TemplateOperations
      • XenException
      • XenHostInfo
      • XenObject
      • XenResponse
      • XenStorageRepository
      • XenTempIso
      • XenTemplate
      • XenVirtualDisk
      • XenVirtualMachine
      • XenVmPowerState
    • Neon.Xunit
      • AnsiblePlayResults
      • AnsiblePlayer
      • AnsibleTaskResult
      • AspNetFixture
      • BasicFixture
      • CodeFixture
      • CollectionComparer<T>
      • ComposedFixture
      • ContainerFixture
      • ContainerLimits
      • DockerComposeFixture
      • DockerFixture
      • DockerFixture.ConfigInfo
      • DockerFixture.ContainerInfo
      • DockerFixture.NetworkInfo
      • DockerFixture.SecretInfo
      • DockerFixture.ServiceInfo
      • DockerFixture.StackDefinition
      • DockerFixture.StackInfo
      • DockerFixture.StackService
      • EnvironmentFixture
      • HostsFixture
      • ITestFixture
      • IncompatibleServiceException
      • MaintainerFactAttribute
      • MaintainerTheoryAttribute
      • MockHttpServer
      • MockHttpServerExtensions
      • NatsFixture
      • NatsStreamingFixture
      • NeonServiceFixture<TService>
      • PlatformFactAttribute
      • RepeatAttribute
      • TargetPlatforms
      • TestArea
      • TestCollection
      • TestContext
      • TestFixture
      • TestFixtureStatus
      • TestHelper
      • TestHttpClient
      • TestOutputWriter
      • TestTrait
      • XunitExtensions
    • Neon.Xunit.YugaByte
      • YugaByteFixture
    • Neon.YugaByte
      • YugaByteHelper

    Class SubStream

    Implements a Stream that operates on a section of a base stream. The base stream must be able to CanSeek.

    note

    Thread safety: multiple SubStream instances can perform operations on the same underlying stream on differents because substreams obtain a lock on the base stream before actually performing any I/O operations.

    note

    WARNING: Avoid performing operations on the underlying stream and any substreams within different threads. This will likey result in unexpected data corruption.

    Inheritance
    object
    MarshalByRefObject
    Stream
    SubStream
    Namespace: Neon.IO
    Assembly: Neon.Common.dll
    Syntax
    public class SubStream : Stream
    Remarks
    note

    This class doesn't currently implement all of the Stream methods, especially asynchronous methods. This is something we may add in the future.

    Constructors

    SubStream(Stream, long, long)

    Constructs a substream that operates on a range of bytes within a base stream.

    Declaration
    public SubStream(Stream baseStream, long start, long length)
    Parameters
    Type Name Description
    Stream baseStream

    The base stream.

    long start

    The zero-based index of the first byte within the base stream to be managed by the substream.

    long length

    The number of bytes to be managed.

    Exceptions
    Type Condition
    IOException

    Thrown if the base stream doesn't support seek or the starting position or length is invalid.

    Properties

    CanRead

    When overridden in a derived class, gets a value indicating whether the current stream supports reading.

    Declaration
    public override bool CanRead { get; }
    Property Value
    Type Description
    bool

    true if the stream supports reading; otherwise, false.

    Overrides
    Stream.CanRead

    CanSeek

    When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

    Declaration
    public override bool CanSeek { get; }
    Property Value
    Type Description
    bool

    true if the stream supports seeking; otherwise, false.

    Overrides
    Stream.CanSeek

    CanWrite

    When overridden in a derived class, gets a value indicating whether the current stream supports writing.

    Declaration
    public override bool CanWrite { get; }
    Property Value
    Type Description
    bool

    true if the stream supports writing; otherwise, false.

    Overrides
    Stream.CanWrite

    Length

    When overridden in a derived class, gets the length in bytes of the stream.

    Declaration
    public override long Length { get; }
    Property Value
    Type Description
    long

    A long value representing the length of the stream in bytes.

    Overrides
    Stream.Length
    Exceptions
    Type Condition
    NotSupportedException

    A class derived from Stream does not support seeking and the length is unknown.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Position

    When overridden in a derived class, gets or sets the position within the current stream.

    Declaration
    public override long Position { get; set; }
    Property Value
    Type Description
    long

    The current position within the stream.

    Overrides
    Stream.Position
    Exceptions
    Type Condition
    IOException

    An I/O error occurs.

    NotSupportedException

    The stream does not support seeking.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Methods

    BeginRead(byte[], int, int, AsyncCallback, object)

    Not Implemented

    Declaration
    public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
    Parameters
    Type Name Description
    byte[] buffer
    int offset
    int count
    AsyncCallback callback
    object state
    Returns
    Type Description
    IAsyncResult
    Overrides
    Stream.BeginRead(byte[], int, int, AsyncCallback, object)

    BeginWrite(byte[], int, int, AsyncCallback, object)

    Not Implemented

    Declaration
    public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
    Parameters
    Type Name Description
    byte[] buffer
    int offset
    int count
    AsyncCallback callback
    object state
    Returns
    Type Description
    IAsyncResult
    Overrides
    Stream.BeginWrite(byte[], int, int, AsyncCallback, object)

    CopyToAsync(Stream, int, CancellationToken)

    Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token. Both streams positions are advanced by the number of bytes copied.

    Declaration
    public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Stream destination

    The stream to which the contents of the current stream will be copied.

    int bufferSize

    The size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    Task

    A task that represents the asynchronous copy operation.

    Overrides
    Stream.CopyToAsync(Stream, int, CancellationToken)
    Exceptions
    Type Condition
    ArgumentNullException

    destination is null.

    ArgumentOutOfRangeException

    buffersize is negative or zero.

    ObjectDisposedException

    Either the current stream or the destination stream is disposed.

    NotSupportedException

    The current stream does not support reading, or the destination stream does not support writing.

    Dispose(bool)

    Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Overrides
    Stream.Dispose(bool)

    DisposeAsync()

    Not Implemented

    Declaration
    public override ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask
    Overrides
    Stream.DisposeAsync()

    EndRead(IAsyncResult)

    Not Implemented

    Declaration
    public override int EndRead(IAsyncResult asyncResult)
    Parameters
    Type Name Description
    IAsyncResult asyncResult
    Returns
    Type Description
    int
    Overrides
    Stream.EndRead(IAsyncResult)

    EndWrite(IAsyncResult)

    Not Implemented

    Declaration
    public override void EndWrite(IAsyncResult asyncResult)
    Parameters
    Type Name Description
    IAsyncResult asyncResult
    Overrides
    Stream.EndWrite(IAsyncResult)

    Flush()

    When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

    Declaration
    public override void Flush()
    Overrides
    Stream.Flush()
    Exceptions
    Type Condition
    IOException

    An I/O error occurs.

    FlushAsync(CancellationToken)

    Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

    Declaration
    public override Task FlushAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    Task

    A task that represents the asynchronous flush operation.

    Overrides
    Stream.FlushAsync(CancellationToken)
    Exceptions
    Type Condition
    ObjectDisposedException

    The stream has been disposed.

    Read(byte[], int, int)

    When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

    Declaration
    public override int Read(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    byte[] buffer

    An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

    int offset

    The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

    int count

    The maximum number of bytes to be read from the current stream.

    Returns
    Type Description
    int

    The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if count is 0 or the end of the stream has been reached.

    Overrides
    Stream.Read(byte[], int, int)
    Exceptions
    Type Condition
    ArgumentException

    The sum of offset and count is larger than the buffer length.

    ArgumentNullException

    buffer is null.

    ArgumentOutOfRangeException

    offset or count is negative.

    IOException

    An I/O error occurs.

    NotSupportedException

    The stream does not support reading.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Read(Span<byte>)

    Not Implemented

    Declaration
    public override int Read(Span<byte> buffer)
    Parameters
    Type Name Description
    Span<byte> buffer
    Returns
    Type Description
    int
    Overrides
    Stream.Read(Span<byte>)

    ReadAsync(byte[], int, int, CancellationToken)

    Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

    Declaration
    public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    byte[] buffer

    The buffer to write the data into.

    int offset

    The byte offset in buffer at which to begin writing data from the stream.

    int count

    The maximum number of bytes to read.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    Task<int>

    A task that represents the asynchronous read operation. The value of the TResult parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if count is 0 or if the end of the stream has been reached.

    Overrides
    Stream.ReadAsync(byte[], int, int, CancellationToken)
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null.

    ArgumentOutOfRangeException

    offset or count is negative.

    ArgumentException

    The sum of offset and count is larger than the buffer length.

    NotSupportedException

    The stream does not support reading.

    ObjectDisposedException

    The stream has been disposed.

    InvalidOperationException

    The stream is currently in use by a previous read operation.

    ReadAsync(Memory<byte>, CancellationToken)

    Not Implemented

    Declaration
    public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Memory<byte> buffer
    CancellationToken cancellationToken
    Returns
    Type Description
    ValueTask<int>
    Overrides
    Stream.ReadAsync(Memory<byte>, CancellationToken)

    ReadByte()

    Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

    Declaration
    public override int ReadByte()
    Returns
    Type Description
    int

    The unsigned byte cast to an int, or -1 if at the end of the stream.

    Overrides
    Stream.ReadByte()
    Exceptions
    Type Condition
    NotSupportedException

    The stream does not support reading.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Seek(long, SeekOrigin)

    When overridden in a derived class, sets the position within the current stream.

    Declaration
    public override long Seek(long offset, SeekOrigin origin)
    Parameters
    Type Name Description
    long offset

    A byte offset relative to the origin parameter.

    SeekOrigin origin

    A value of type SeekOrigin indicating the reference point used to obtain the new position.

    Returns
    Type Description
    long

    The new position within the current stream.

    Overrides
    Stream.Seek(long, SeekOrigin)
    Exceptions
    Type Condition
    IOException

    An I/O error occurs.

    NotSupportedException

    The stream does not support seeking, such as if the stream is constructed from a pipe or console output.

    ObjectDisposedException

    Methods were called after the stream was closed.

    SetLength(long)

    When overridden in a derived class, sets the length of the current stream.

    Declaration
    public override void SetLength(long value)
    Parameters
    Type Name Description
    long value

    The desired length of the current stream in bytes.

    Overrides
    Stream.SetLength(long)
    Exceptions
    Type Condition
    IOException

    An I/O error occurs.

    NotSupportedException

    The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Write(byte[], int, int)

    When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

    Declaration
    public override void Write(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    byte[] buffer

    An array of bytes. This method copies count bytes from buffer to the current stream.

    int offset

    The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

    int count

    The number of bytes to be written to the current stream.

    Overrides
    Stream.Write(byte[], int, int)
    Exceptions
    Type Condition
    ArgumentException

    The sum of offset and count is greater than the buffer length.

    ArgumentNullException

    buffer is null.

    ArgumentOutOfRangeException

    offset or count is negative.

    IOException

    An I/O error occurred, such as the specified file cannot be found.

    NotSupportedException

    The stream does not support writing.

    ObjectDisposedException

    Write(byte[], int, int) was called after the stream was closed.

    Write(ReadOnlySpan<byte>)

    When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

    Declaration
    public override void Write(ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> buffer

    A region of memory. This method copies the contents of this region to the current stream.

    Overrides
    Stream.Write(ReadOnlySpan<byte>)

    WriteAsync(byte[], int, int, CancellationToken)

    Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

    Declaration
    public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    byte[] buffer

    The buffer to write data from.

    int offset

    The zero-based byte offset in buffer from which to begin copying bytes to the stream.

    int count

    The maximum number of bytes to write.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    Task

    A task that represents the asynchronous write operation.

    Overrides
    Stream.WriteAsync(byte[], int, int, CancellationToken)
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null.

    ArgumentOutOfRangeException

    offset or count is negative.

    ArgumentException

    The sum of offset and count is larger than the buffer length.

    NotSupportedException

    The stream does not support writing.

    ObjectDisposedException

    The stream has been disposed.

    InvalidOperationException

    The stream is currently in use by a previous write operation.

    WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

    Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

    Declaration
    public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    ReadOnlyMemory<byte> buffer

    The region of memory to write data from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    ValueTask

    A task that represents the asynchronous write operation.

    Overrides
    Stream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

    WriteByte(byte)

    Writes a byte to the current position in the stream and advances the position within the stream by one byte.

    Declaration
    public override void WriteByte(byte value)
    Parameters
    Type Name Description
    byte value

    The byte to write to the stream.

    Overrides
    Stream.WriteByte(byte)
    Exceptions
    Type Condition
    IOException

    An I/O error occurs.

    NotSupportedException

    The stream does not support writing, or the stream is already closed.

    ObjectDisposedException

    Methods were called after the stream was closed.

    Extension Methods

    IOExtensions.DeflateTo(Stream, Stream)
    IOExtensions.GunzipTo(Stream, Stream)
    IOExtensions.GzipTo(Stream, Stream)
    IOExtensions.InflateTo(Stream, Stream)
    IOExtensions.ReadBytes(Stream, int)
    IOExtensions.ReadToEnd(Stream)
    IOExtensions.ReadToEndAsync(Stream)
    IOExtensions.Write(Stream, byte[])
    IOExtensions.WriteAsync(Stream, byte[])
    In this article
    Back to top © Copyright 2005-2023 by NEONFORGE LLC