Sunday, February 21, 2010

How to Write and Read Some Content into (or from) File Using Java Script

To write some content into some file or read content from file and wants to store all file content in one variable and wants to dispaly this as a alert or some thing the following program will be helpful.This works in Internet Explorer.


<SCRIPT language="JavaScript">

function WriteAndReadFile()


var fso = new ActiveXObject("Scripting.FileSystemObject");

var fh = fso.CreateTextFile("D:\\Test.txt", true);

fh.WriteLine("Text Example 1");

fh.WriteLine("Text Example 2");

fh.WriteLine("Text Example 3");

var f;

var str;

f = fso.OpenTextFile("D:\\Test.txt", 1);

var s=f.ReadAll();








<SCRIPT language="JavaScript"> WriteAndReadFile(); </SCRIPT>




No comments:

Post a Comment