Which FileShare option is used with FileInfo.OpenRead method?

609 Views Asked by At

On .NET Framework documentation says that when I use FileInfo.OpenRead method a read-only FileStream is created but, which FileShare option is internally used?

Once I've opened the file is read or write locked?

2

There are 2 best solutions below

1
Cee McSharpface On BEST ANSWER

A quick look in reference source reveals that it is

FileShare.Read

This setting is documented to

allow[s] subsequent opening of the file for reading

2
mjwills On

As per the documentation:

This method returns a read-only FileStream object with the FileShare mode set to Read.