File Size Demo

This script uses the FileSystemObject to determine the File size of this particular Web page (/demos/FileSizeFAQDemo.asp).


The file D:\websites\b2b\4guysfromrolla.com\aspsite\wwwroot\www\demos\FileSizeFAQDemo.asp is 1,440 bytes in size.


Souce Code:
<%
  'How big is this file?
  Dim strFileName
  strFileName = Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))

  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Dim iFileSize
  iFileSize = objFSO.GetFile(strFileName).Size

  Response.Write "The file <code>" & strFileName & "</code> is " & FormatNumber(iFileSize, 0) & _
                 " bytes in size."

  Set objFSO = Nothing
%>
  


[Return to the FAQ]