Javascript FSO DateLastAccessed Property

Updated on 30 Mar 2012,
Published on 12 Nov 2008

The DateLastAccessed property of Javascript FileSystemObject (FSO) associated with file object or folder object returns the combined result of date and time of a specified file or folder when it was last accessed. DateLastAccessed property is accessible through both types of objects i.e. file object as well as folder object that returns the date and time when it was last accessed. Javascript FSO GetFile method returns the File object that allows the access to DateLastAccessed property and GetFolder method returns the folder object that also supports this property.

Syntax for Javascript FSO DateLastAccessed Property

fileObj.DateLastAccessed

// or
folderObj.DateLastAccessed

Both above syntaxes show the way of using the file object and folder object to access the DateLastAccessed property.

Example 1

File Object to get the value of DateLastAccessed Property

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

    // object created for file object returned by GetFile method
    var fileObj = fso.GetFile("C:\\Temp\\textFile.txt");
    document.write("<b>File DateLastAccessed: </b>" + fileObj.DateLastAccessed);
    document.write("<br />");

    // Output: 
    // File DateLastAccessed: Tue Oct 7 02:53:27 EDT 2008
</script> 

Example 2

Folder Object to get the value of DateLastAccessed Property

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

    // object created for folder object returned by GetFolder method
    var folderObj = fso.GetFolder("C:\\Temp\\myFolder");
    document.write("<b>Folder DateLastAccessed: </b>" + folderObj.DateLastAccessed);
    document.write("<br />");

    // Output: 
    // Folder DateLastAccessed: Tue Oct 7 02:44:12 EDT 2008
</script>

Continue to next tutorial: Javascript FSO DateLastModified Property to learn how to get the date when the specified file or folder was last modified.

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