Legacy FileStream strategy removed

The AppContext switch System.IO.UseNet5CompatFileStream and the ability to use the legacy FileStream implementation were removed.

Previous behavior

The legacy FileStream implementation was available and you could opt in to it by using the UseNet5CompatFileStream switch or the DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM environment variable.

New behavior

Starting in .NET 7, you can no longer opt in to use the legacy FileStream implementation.

Version introduced

.NET 7 Preview 1

Type of breaking change

This change can affect binary compatibility.

Reason for change

The UseNet5CompatFileStream switch and DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM environment variable were included in .NET 6 in case the new implementation caused breaking changes. Any breaking changes have now been fixed. Since there are no more bugs introduced by the FileStream changes, the compatibility mode was removed and with it all the legacy code, which makes the codebase easier to maintain.

If you're currently using the switch (or the DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM environment variable) to opt in to legacy code and are upgrading to .NET 7, the switch will no longer have any effect and you should remove it.

Affected APIs

See also