ReadAllBytes(string)
Reads all bytes from a file, resolving logical paths automatically.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
public static byte[] ReadAllBytes(string path)
Parameters
Path to the file. Accepts logical and physical paths.
Returns
Type | Description |
|---|---|
| byte[] | The entire file content as a byte array. |
Remarks
Reads and returns all bytes in the file at . Unlike , this method accepts logical paths directly without first converting them with FileUtil.PathToAbsolutePath.
pathFile.ReadAllBytesThrows ArgumentException when is null or empty.
pathExamples
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."); }}