Forum Discussion

Shivani3's avatar
Occasional Contributor
12 months ago

How to write string n file

How to add one string just below the existing line in a text file and also how we can save that file using javascript and test complete tool?

3 Replies

    • Shivani3's avatar
      Occasional Contributor

      But with that it is only possible to skip the number of lines and the  it is replacing the existing text. But I don't want to replace that text I just want to create new line below the existing line then write on that line.

  • rraghvani's avatar
    Champion Level 3

    You can also use Scripting.FileSystemObject as shown below, which appends a string to the end of file.

    function AppendFile()
        let FS = getActiveXObject("Scripting.FileSystemObject");
        let F = FS.OpenTextFile("C:\\Temp\\MyTest.txt", 8);


    Again, you will have to create your own function, if you want to write a string to a specific location.