Skip to content

Platform-dependent FileStream permissions behavior? #24432

@nickwalkmsft

Description

@nickwalkmsft

I might be missing something obvious, but it's strange to me that this throws an IOException on Windows but not on Ubuntu:

var willWork = File.Open(myPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
var willThrowOnlyOnWin = File.Open(myPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

However, this will throw on both:

var willWork = File.Open(myPath, FileMode.Create, FileAccess.ReadWrite, **FileShare.None**);
var willThrowEverywhere = File.Open(myPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions