Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created June 22, 2022 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulbanerjee26/145230377250948113b60f0bb7381a22 to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/145230377250948113b60f0bb7381a22 to your computer and use it in GitHub Desktop.
function readFromFile(path, data, ForReading){
//create and write to the previous file
var writeSystemObject = new ActiveXObject("Scripting.FileSystemObject");
var writeStream = writeSystemObject.CreateTextFile(path,true);
writeStream.Write(data);
writeStream.close();
//Read from the file
var readSystemObject = new ActiveXObject("Scripting.FileSystemObject");
var readStream = readSystemObject.OpenTextFile(path, ForReading);
var text = readStream.ReadLine();
console.log("Text read from file: "+text)
readStream.close();
}
readFromFile("C:\\theFile.txt", "This text was written using a TextStream",1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment