Background and motivation
FileStream has a few constructors with a non-optional bufferSize, and there is currently no way to pass a value (either 0 or -1) to get the default behavior, as in constructors that do not take it. That's why I propose just exposing the DefaultBufferSize so that we don't have to hardcode 4096 everywhere, because that is the current default.
API Proposal
namespace System.IO;
public partial class FileStream : Stream
{
public const int DefaultBufferSize = 4096;
// or
public static int DefaultBufferSize { get; }
}
API Usage
using var fileStrem = new FileStream(
fileHandle,
FileAccess.Read,
FileStream.DefaultBuffersize,
isAsync: true);
Alternative Designs
No response
Risks
No response
Background and motivation
FileStream has a few constructors with a non-optional bufferSize, and there is currently no way to pass a value (either 0 or -1) to get the default behavior, as in constructors that do not take it. That's why I propose just exposing the
DefaultBufferSizeso that we don't have to hardcode 4096 everywhere, because that is the current default.API Proposal
API Usage
Alternative Designs
No response
Risks
No response