| Parameter | Description |
|---|---|
| path | Path to the file. Accepts logical and physical paths. |
string[]
An array containing one element per line. Lines are split on \r\n and \n.
Reads all lines from a file, resolving logical paths automatically.
Reads the entire file at path and returns its lines as a string array. Unlike File.ReadAllLines, 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.ReadAllText, FileUtil.ReadAllBytes, FileUtil.OpenRead
using UnityEditor; using UnityEngine;
public class ReadAllLinesExample { [MenuItem("Example/Read File Lines")] static void ReadFileLines() { string[] lines = FileUtil.ReadAllLines("Packages/com.example.package/Resources/manifest.txt"); foreach (string line in lines) Debug.Log(line); } }