I am trying to figure out how to read the complete content of a .txt file using JavaScript. I know that ReadLine() can be used to read a specific line from a file, but I need a method that will allow me to read the entire contents of the file. I have searched online extensively for a solution without any luck.
Below is the code I am currently using:
var ForReading = 1;
var TristateUseDefault = -2;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newFile = fso.OpenTextFile(sFileName, ForReading, true, TristateUseDefault);
var importTXT = newFile.ReadLine();
As it stands, this code only reads the first line of the .txt file into the importTXT variable. However, my goal is to retrieve the entire file content and store it in importTXT.
If anyone has any suggestions or solutions, I would greatly appreciate it.