Friday, July 3, 2015

Read & Write a File with JavaScript

Sample code to do the File manipulation in JavaScript.
This code illustrate, how to Create, Read & Write the text in file using the Java Script.

Code:

           // Reading text file.

           var fso  = new ActiveXObject("Scripting.FileSystemObject");
           var fhRead = fso.OpenTextFile("C:\\Test.txt",1);
           var Fltext = fhRead.ReadAll();
           fhRead.Close();
 

            // Creating text file.

            var fh = fso.CreateTextFile("C:\\Test.txt", true);
            fh.WriteLine("Sample");
            fh.Close();
         
                 
        

No comments:

Post a Comment