| Parameter | Description |
|---|---|
| path | Path to the file. Accepts logical and physical paths. |
string The entire file content as a string.
Reads all text from a file, resolving logical paths automatically.
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 System.ArgumentException when path is null or empty.
Additional resources: FileUtil.ReadAllLines, FileUtil.ReadAllBytes, FileUtil.OpenRead
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); } }