Click to See Complete Forum and Search --> : [RESOLVED] How do I get the file size in Kb?


Danbabe
08-16-2006, 10:47 AM
Hi guys,

I need to get the size of an existing file in Kb. I have several existing dynamic files (i.e. .jpg, .doc, .xls etc...) and need to record the file size of the known file.

I can acess the file using Server.CreateObject("Scripting.FileSystemObject") and see the file itself OK. I just need to get the file size of anyone can help.

Cheers chaps

Dan

russell
08-16-2006, 10:56 AM
Dim fso '' As Scripting.FileSystemObject
Dim f '' As Scripting.File

Set fso = Server.CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFile(filePathHere)

'' size in bytes. uncomment below for Kb
Response.Write f.Size ' / 1024

Set f = Nothing
Set fso = Nothing

russell
08-16-2006, 11:00 AM
here are the properties and methods of the FSO File Object:
Properties
Attributes
DateCreated
DateLastAccessed
DateLastModified
Drive
Name
ParentFolder
Path
ShortName
ShortPath
Size
Type

Methods
Copy
Delete
Move
OpenAsTextStream

Danbabe
08-16-2006, 11:24 AM
Thanks guys. That has worked beautifully.

Dan