# ReadAllBytes(string)

> Reads all bytes from a file, resolving logical paths automatically.

## Definition

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

```csharp
public static byte[] ReadAllBytes(string path)
```

### Parameters

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

### Returns

| Type                                                           | Description                              |
| -------------------------------------------------------------- | ---------------------------------------- |
| [byte\[\]](https://learn.microsoft.com/dotnet/api/system.byte) | The entire file content as a byte array. |

### Remarks

Reads and returns all bytes in the file at `path`. Unlike `File.ReadAllBytes`, 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.

Additional Resources: [FileUtil.OpenRead](/engine/6000.7/script-reference/unityeditor/fileutil/openread.md), [FileUtil.ReadAllText](/engine/6000.7/script-reference/unityeditor/fileutil/readalltext.md), [FileUtil.ReadAllLines](/engine/6000.7/script-reference/unityeditor/fileutil/readalllines.md)

### Examples

```csharp
using UnityEditor;
using UnityEngine;

public class ReadAllBytesExample
{
    [MenuItem("Example/Read File Bytes")]
    static void ReadFileBytes()
    {
        byte[] data = FileUtil.ReadAllBytes("Packages/com.example.package/Resources/data.bytes");
        Debug.Log("Read " + data.Length + " bytes.");
    }
}
```
