Javascript FSO Size Property
Size Property of Javascript FileSystemObject (FSO) can be accessed using file object or folder object returned by the GetFile method or GetFolder method. Size property returns the size of the specified file or folder in bytes.
Syntax for FSO Size Property
fileObj.Size // or folderObj.Size
You can use any of the above syntax to retrieve the size of the specified file or folder based on the type of object used to access the Size property. GetFile method returns the file object that will return the size of the specified file whereas GetFolder method returns the folder object that will further return the size of the specified folder. Both these method provide the access to the Size property that returns the size of the specified file or folder.
Example 1
File object to get Size 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 Size : </b>" + fileObj.Size + " bytes");
document.write("<br />");
// Output
// File Size : 7 bytes
</script>
Example 2
Folder object to get Size 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 Size : </b>" + folderObj.Size + " bytes");
document.write("<br />");
// Output
// Folder Size : 133 bytes
</script>
Continue to next tutorial: Javascript FSO Type property to learn how to get the type of file or folder.

* will not be published
* hint: http://www.example.com