Search code examples
wshjscriptwindows-scripting

End of file in JavaScript


I want to read a local file line by line in JavaScript. Ut I can check if it goes to the end of this file. For example:

file = new ActiveXObject("Scripting.FileSystemObject"); 

// Sets the variable "f" to equal the new open file contents 

f = file.OpenTextFile("c:\\wantlist.txt", 1); 
s = f.ReadLine()

While(s != EOF)
{
    //. Do some thing 
    s = f.ReadLine()
}

What is EOF should be in JavaScript? Or do you have another way to deal with this problem? Thank you very much!


Solution

  • Try:

    f.AtEndOfStream
    

    http://msdn.microsoft.com/en-us/library/ffk3x3bw%28v=vs.84%29.aspx