Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

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
path
. Unlike
File.ReadAllBytes
, this method accepts logical paths directly without first converting them with FileUtil.PathToAbsolutePath.
Throws ArgumentException when
path
is null or empty.

Examples

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."); }}