OpenRead Method

FileInfo.OpenRead Method ()


Creates a read-only FileStream.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

public FileStream OpenRead()

Return Value

Type: System.IO.FileStream

A new read-only FileStream object.

Exception Condition

path is read-only or is a directory.


The specified path is invalid, such as being on an unmapped drive.


The file is already open.

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

The following example opens a file as read-only and reads from it.

Snippet section 1 of code snippet {"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"26f476f4-3870-4594-af09-06e6aef6831b","entity_type":"CodeSnippet","locale":"en-US"} in source file ({"filename":"/CS/finfo openread.cs","blob_type":"Source","blob_id":"-002fcs-002ffinfo-0020openread-002ecs","blob_revision":3}), line 1 is missing the closing tag.


for reading files. Associated enumeration: FileIOPermissionAccess.Read

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft