Javascript FSO textstream File Close Method

Updated on 29 Mar 2012,
Published on 14 Oct 2008

Javascript FileSystemObject (FSO) textstream object’s Close method provides the functionality to close an open textstream file object. FSO OpenTextFile method opens the textstream of the specified file and Close method provided by the textstream object returned by the OpenTextFile method closes that textstream. 

Syntax for Javascript FSO textstream File Close Method

textstreamObj.Close();

Close method of textstream object does not take any parameter to perform the action as shown in the above syntax.

Example of FSO textstream File Close method

<script type="text/javascript">
    // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
    var fso = new ActiveXObject("Scripting.FileSystemObject");

    // Open the text file at the specified location with write mode
    var txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 2, false, 0);
    txtFile.WriteLine("Hello this is the first line of text file.");
    txtFile.WriteLine("Hello this is the second line of text file.");
    txtFile.WriteLine("Hello this is the third line of text file.");

    // close the open textstream object file
    txtFile.Close();
    fso = null 
</script>

Continue to next tutorial: Javascript FSO textstream File Read Method to learn how to read the specified number of characters from the textstream.

0 Responses to "Javascript FSO textstream File Close Method"
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email
  • HIRE EzineASP.Net Developers