Reading a specific line from a file.

I’m working in Javascript.

I need to read a specific portion of a file and I don’t want to waste time reading the entire file to an array and then selecting the data I need.

I’m using the StreamReader Class, but it doesn’t appear to have a SkipLine or Skip method… Is there another way of moving to a specific part of a file for reading?

You aren’t “wasting time” by reading in the previous lines first. In text files, lines are characters, generally ’
', just like all the other characters in the file. There’s no way to skip ahead to the Nth line in a generic text file without reading all the previous lines.

I would suggest you for you to not worry about performance issues until they actually become a problem.

I believe this does it, puts them all in array, its a bit shorter than parsing manually:

        var arrLine : String[] = File.ReadAllLines(fileName);
        arrLine[line_to_edit - 1] = newText;
        File.WriteAllLines(fileName, arrLine);