Hi everyone,
Can someone give me a simple example code that loads every line from text file into array separately? I spent quite a few hours searching for answers, but nothing.
Thanks!
Here is what I got for you from my text project.
Here is get path
string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
Load file
FileStream fs = new FileSteam(path, FileMode.Open);
string content = "";
using (StreamReader read = new StreamReader(fs, true))
{
content = read.ReadToEnd();
}
Replace all newline part
string[] result = content.Regex.Split(content, "
?|
", RegexOptions.Singleline);
works fine, system IO
var textFilePath : String = Application.dataPath + "/TEXT/" + "hb.txt";
var arrLine : String[] = File.ReadAllLines(textFilePath);
print (arrLine[3]);
@Toon_Werawat ,“content.Regex.Split” gives me an error : ‘string’ does not contain a definition for ‘Regex’.