Try this:

<%
Function GetFileSize(FileName)
   Dim fso, f, FilePath
   FilePath = Server.MapPath("A_Folder/" & FileName)
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(FilePath)
   GetFileSize = FileSizeString(f.Size)
End Function

Function FileSizeString(ByVal decFileSize)
  Dim vaUnits
  Dim iUnitIndex
  'up to 1024 PetaBytes should be OK for now...
  vaUnits = Array(" Bytes", " kb", " Mb", " Gb", " Tb", " Pb")
  While decFileSize > 1024
  decFileSize = decFileSize / 1024
  iUnitIndex = iUnitIndex + 1
  Wend
  FileSizeString = FormatNumber(decFileSize, 2) & vaUnits(iUnitIndex)
End Function

Response.Write GetFileSize("word.doc")
%>

HTH
Sam

----- Original Message -----
From: "jake williamson" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Wednesday, November 06, 2002 6:08 PM
Subject: showing file size in meg


hello!

got this real cool file system thing building at the moment for our
clients to log in and download pdf proofs.

it's a real small cosmetic thing but i'd like to show the size in
'finder' style. at the moment my code:

<% = objFile.Size %>

gives me:

1489493

if i do:

<% = objFile.Size / 1000 %>

to divide it into k i get:

1489.493

when what i really want is:

1.489

or preferably:

1.4

is this gonna be a complete pain or is it dead easy??

thanks out here lads and lass',

jake

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to