Xceed .NET Libraries Documentation
Xceed.FileSystem Assembly / Xceed.FileSystem Namespace / AbstractFile Class / GetStreamBufferSize Method

A reference to a FileSystemEventsSession object that is responsible for raising all events that occur during the process.
Can be null.

A Stream object from which data will be read. Can be null.

A Stream object to which data will be written. Can be null.

A FileSystemItem object into which the file will be copied. Can be null.



In This Topic
    GetStreamBufferSize Method (AbstractFile)
    In This Topic
    Returns the recommended buffer size for a stream copy operation.
    Syntax
    'Declaration
     
    
    Protected Overridable Function GetStreamBufferSize( _
       ByVal session As FileSystemEventsSession, _
       ByVal sourceStream As Stream, _
       ByVal destinationStream As Stream, _
       ByVal destinationFile As FileSystemItem _
    ) As Integer
    'Usage
     
    
    Dim instance As AbstractFile
    Dim session As FileSystemEventsSession
    Dim sourceStream As Stream
    Dim destinationStream As Stream
    Dim destinationFile As FileSystemItem
    Dim value As Integer
     
    value = instance.GetStreamBufferSize(session, sourceStream, destinationStream, destinationFile)

    Parameters

    session

    A reference to a FileSystemEventsSession object that is responsible for raising all events that occur during the process.
    Can be null.

    sourceStream
    A Stream object from which data will be read. Can be null.
    destinationStream

    A Stream object to which data will be written. Can be null.

    destinationFile

    A FileSystemItem object into which the file will be copied. Can be null.

    Return Value

    A value representing the recommended buffer size for a stream copy operation.
    Remarks

    Methods like CopyTo that perform stream copy operations will call this method to get the buffer
    size to use.

    The returned value will always be greater than zero.

    The default implementation of the method uses the value given by AbstractFile.DefaultStreamBufferSize.

    Derived types can override this method and provide a value suited to the media involved and the
    supplied parameters.

    In most cases, it is not necessary to override the default implementation of this method.

    Care must be taken when choosing a buffer size. If the value is too small, the loop count and the number of function calls increase, impacting performance. If the value is too large memory can be used up with no improvements in performance.

    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Standard: netstandard2.0, netstandard2.1

    .NET Framework: net20, net35, net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also