# OpenRead(string)

> Opens a file for reading, resolving logical paths automatically.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static Stream OpenRead(string path)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path to the file. Accepts logical and physical paths.

### Returns

| Type                                                              | Description                                                                 |
| ----------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream) | A read-only Stream over the file content. Dispose the stream when finished. |

### Remarks

Returns a readable Stream for the file at `path`. Unlike `File.Open`, this method accepts logical paths directly without first converting them with [FileUtil.PathToAbsolutePath](/engine/6000.7/script-reference/unityeditor/fileutil/pathtoabsolutepath.md).

Throws ArgumentException when `path` is null or empty. Throws IOException when the file cannot be opened.

Additional Resources: [FileUtil.ReadAllBytes](/engine/6000.7/script-reference/unityeditor/fileutil/readallbytes.md), [FileUtil.ReadAllText](/engine/6000.7/script-reference/unityeditor/fileutil/readalltext.md), [FileUtil.ReadAllLines](/engine/6000.7/script-reference/unityeditor/fileutil/readalllines.md), [FileUtil.PathToAbsolutePath](/engine/6000.7/script-reference/unityeditor/fileutil/pathtoabsolutepath.md)

### Examples

```csharp
using System.IO;
using UnityEditor;
using UnityEngine;

public class OpenReadExample
{
    [MenuItem("Example/Read File As Stream")]
    static void ReadAsStream()
    {
        using (Stream stream = FileUtil.OpenRead("Packages/com.example.package/Resources/config.bytes"))
        using (var reader = new BinaryReader(stream))
        {
            int version = reader.ReadInt32();
            Debug.Log("Config version: " + version);
        }
    }
}
```
