The enum values state/imply that the effect is applied on "subsequent opening of the file". This is not correct because the value can cause the current file open request to fail based on previously opened file handles.
For example, the FileShare.Read value states the following:
Allows subsequent opening of the file for reading. If this flag is not specified, any request to open the file for reading (by this process or another process) will fail until the file is closed.
In the code below, the second attempt to open the file will fail because it is specifying FileShare.Read and the previous file open request has Write access to the file.
using var fileStream1 = new FileStream("test.file", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
using var fileStream2 = new FileStream("test.file", FileMode.Open, FileAccess.Read, FileShare.Read);
Please update the documentation so that it is clear that the FileShare value applies to existing file handles as well as future attempts to open the file.
Type of issue
Other (describe below)
Description
The enum values state/imply that the effect is applied on "subsequent opening of the file". This is not correct because the value can cause the current file open request to fail based on previously opened file handles.
For example, the FileShare.Read value states the following:
In the code below, the second attempt to open the file will fail because it is specifying FileShare.Read and the previous file open request has Write access to the file.
Please update the documentation so that it is clear that the FileShare value applies to existing file handles as well as future attempts to open the file.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.io.fileshare?view=net-8.0
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.IO/FileShare.xml
Document Version Independent Id
3bd9dbb8-0a53-ad3f-cd5d-c18d47f7f1a1
Article author
@dotnet-bot