Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ReadAllText(string)

Reads all text from a file, resolving logical paths automatically.
Read time 1 minuteLast updated 7 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule
public static string ReadAllText(string path)

Parameters

path

Path to the file. Accepts logical and physical paths.

Returns

Type

Description

stringThe entire file content as a string.

Remarks

Reads and returns the full text content of the file at
path
. Unlike
File.ReadAllText
, 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 ReadAllTextExample{ [MenuItem("Example/Read File Text")] static void ReadFileText() { string text = FileUtil.ReadAllText("Packages/com.example.package/Resources/config.json"); Debug.Log(text); }}