# ReadAllBytes(string)

> Opens a binary file, reads the contents of the file into a byte array, and then closes the file.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Windows](/engine/6000.5/script-reference/unityengine/windows.md)
* **Assembly:** UnityEngine.CoreModule

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Complete path of the file to open for reading.

### Returns

| Type                                                           | Description                                          |
| -------------------------------------------------------------- | ---------------------------------------------------- |
| [byte\[\]](https://learn.microsoft.com/dotnet/api/system.byte) | Managed array of bytes of the complete file content. |

### Remarks

If the file is not found, the function returns an empty array of bytes ( size=0 ).

### Examples

```csharp
var filePath = "path_to_your_file/yourfile.dat";

// Check if the file exists
if (File.Exists(filePath))
{
    // Read the entire file into a byte array
    var fileData = File.ReadAllBytes(filePath);

    // Output the size of the file
    Debug.Log($"File size: {fileData.Length} bytes");
}
else
{
    Debug.LogError($"File not found at path: {filePath}");
}
```
