The ASP size property is used to return the size of the specified file or folder. It returns the value in terms of bytes.
Syntax:
- For file Object:
FileObject.Size
- For folder Object:
FolderObject.Size
Example-1: Below code returns the size of a file.
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile("d:\GFG.asp")
Response.Write("The size of GFG.asp is: ")
Response.Write(f.Size & " bytes.")
set f=nothing
set fs=nothing
%>
Output:
The size of GFG.asp is: 100323 bytes.
Example-2: Below code returns a size of a folder.
<%
dim fs,fo
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("d:\GFG")
Response.Write("The size of the folder test is: ")
Response.Write(fo.Size & " bytes.")
set fo=nothing
set fs=nothing
%>
Output
The size of the folder test is: 123456 bytes.