FileShare Enumeration
Summary
Specifies the type of access a FileShare
object has to a file.
Members
Allows subsequent opening of the file for reading. No other processes can open the file for writing.
Allows subsequent opening of the file for writing. No other processes can open the file for reading or writing.
Allows subsequent opening of the file for reading or writing. No other processes can open the file for reading or writing.
Allows subsequent opening and deletion of the file. No other processes can open the file for reading, writing, or deletion.
Specifies that the share mode applies to the descendants of the file.
Specifies that no other processes can open the file.
Note: This is the default value. The Read
member has the same value.
Syntax
Remarks
This enumeration is used by the constructors of the FileStream
class to control how a file can be shared.
When you create a FileStream
object, you can specify the share mode to indicate whether other processes can access the file while it is open.
For example, to open a file for reading and prevent other processes from writing to it, you would use:
If you want to allow other processes to read and write to the file while it's open, you can use:
The None
and Read
values are equivalent, meaning that if you specify FileShare.None
, other processes can still open the file for reading.