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 to the file. Accepts logical and physical paths.
Returns
Type | Description |
|---|---|
| string | The entire file content as a string. |
Remarks
Reads and returns the full text content of the file at . Unlike , this method accepts logical paths directly without first converting them with FileUtil.PathToAbsolutePath.
pathFile.ReadAllTextThrows ArgumentException when is null or empty.
pathExamples
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); }}