Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ReadAllLines(string)

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

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule
public static string[] ReadAllLines(string path)

Parameters

path

Path to the file. Accepts logical and physical paths.

Returns

Type

Description

string[]An array containing one element per line. Lines are split on
\r\n
and
\n
.

Remarks

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 ArgumentException when
path
is null or empty.

Examples

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