The four-argument overload uses the supplied FileAccess and FileShare values, so FileAccess.Write/FileShare.None means a write-only, unshared stream; remarks describing fixed read/write access or FileShare.Read defaults do not override those explicit arguments.
Published .NET 10 contract
For:
using FileStream stream = new(
path,
FileMode.CreateNew,
FileAccess.Write,
FileShare.None);
the arguments mean:
-
FileMode.CreateNew: create a new file; throw IOException if the file already exists.^1^
-
FileAccess.Write: permit writing, but not reading. The FileAccess reference distinguishes Write from ReadWrite explicitly.^2^
-
FileShare.None: decline sharing while this handle remains open; other attempts to open the file fail until it is closed.^3^
The constructor’s own summary likewise says that this overload initializes the stream with the specified creation mode, read/write permission, and sharing permission.^4^
Consequently:
-
stream.CanWrite is expected to be true.
-
stream.CanRead is expected to be false.
- A read operation through this stream is not enabled merely because a remark mentions read/write access.
-
FileShare.None is the requested sharing mode; it is not replaced with FileShare.Read.
A default applies only when the caller has not supplied that setting. The constructor page itself contains the qualified statement:
FileShare.Read is the default for those FileStream constructors without a FileShare parameter.
That condition excludes the four-argument overload because it has an explicit share parameter.^4^
Similarly, the FileStreamOptions.Share property defaults to FileShare.Read, but that is the default of the options property; it does not replace a FileShare argument passed directly to this constructor.^5^
Microsoft’s .NET 10 File.OpenWrite documentation provides an especially direct cross-check: it says that File.OpenWrite(path) is equivalent to this exact four-argument overload with FileMode.OpenOrCreate, FileAccess.Write, and FileShare.None.^6^ Therefore, Write/None is an expressly documented and supported combination.
Any overload-associated prose stating unconditionally that this constructor provides read/write access and read sharing is inconsistent with the overload summary, parameter definitions, enum contracts, and the documented File.OpenWrite equivalence. It should be treated as misplaced or over-broad documentation, not as a special rule that rewrites the arguments.
Contract versus implementation evidence
The published contract is the version-selected .NET 10 API documentation above. The page’s Source link pins the constructor to a specific repository commit:
That implementation shows the four-argument constructor forwarding path, mode, access, and share unchanged to the fuller constructor, adding only default buffering/asynchronous settings. This is stable implementation evidence for the source snapshot linked from the .NET 10 page, but the Learn API descriptions remain the published contract.
No separate official correction or documentation issue specifically correcting these four-argument Remarks appears in the available references. Until the page is corrected, the overload-specific parameter contract and the documented File.OpenWrite equivalence are the applicable official references.
References
- FileMode Enum-Definition
- FileAccess Enum-Definition
- FileShare Enum-Definition
- FileStream Constructors-Definition
- FileStreamOptions.Share Property-Definition
- File.OpenWrite(String) Method-Definition