We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling FileInfo.Create extension method with FileSystemRights.Read as access rights to create a FileStream.
FileInfo.Create
FileSystemRights.Read
FileStream
FileInfo fi = new(path); FileStream stream = fi.Create( FileMode.Open, FileSystemRights.Read, // <---- Open with read-only access. FileShare.ReadWrite | FileShare.Delete, 4 * KB, FileOptions.None, null); // Check stream.CanWrite!
FileAccess.Read
CanWrite
false
FileAccess.ReadWrite
true
No response
Windows 10, .NET SDK 7.0.203, using System.IO.FileSystem.AccessControl package.
The issue is most probably within the FileSystemAclExtensions.GetFileAccessFromRights method.
FileSystemAclExtensions.GetFileAccessFromRights
Almost any value for the FileSystemRights will match the first condition, and most of them will also match the second.
See:
// rights = FileSystemRights.Read; private static FileAccess GetFileAccessFromRights(FileSystemRights rights) { FileAccess fileAccess = (FileAccess)0; if ((rights & FileSystemRights.FullControl) != 0 || (rights & FileSystemRights.Modify) != 0) { return FileAccess.ReadWrite; // Returns here. }
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Sorry, something went wrong.
No branches or pull requests
Description
Calling
FileInfo.Create
extension method withFileSystemRights.Read
as access rights to create aFileStream
.Reproduction Steps
Expected behavior
FileStream
.FileAccess.Read
.CanWrite
property should read tofalse
.Actual behavior
FileStream
(so far so good).FileStream
file access is wrongly set internally toFileAccess.ReadWrite
.CanWrite
istrue
for the stream. The underlying handle with throw an exception if we try to write.Regression?
No response
Known Workarounds
No response
Configuration
Windows 10, .NET SDK 7.0.203, using System.IO.FileSystem.AccessControl package.
Other information
The issue is most probably within the
FileSystemAclExtensions.GetFileAccessFromRights
method.Almost any value for the FileSystemRights will match the first condition, and most of them will also match the second.
See:
The text was updated successfully, but these errors were encountered: