Calculate file sizes in a webpage

PHTech

Senior Member
Joined
Aug 21, 2006
Messages
588
Reaction score
0
Location
Witbank
Hey...

Is there a way to calculate the size of any file in a webpage (ASP or HTML)..? Or even if there is a JavaScript to this it would be cool...

The reason why I want to do this is that I want to monitor the size of a database on our intranet, and within one page, I want to draw up like a statistics page.

Any help would be appreciated...

Thanx...!
 
Use the Length property of the System.IO.FileInfo class in .NET:

Code:
System.IO.FileInfo dbFile = new System.IO.FileInfo("path to database file");
dbFile.Length;

EDIT: It will return the size of the file in bytes.
 
Well, we haven't answered the OP yet... He requested ASP (presuming classic?) or HTML (a big HUH? to that). So the .NET and PHP answers are probably a no-no... :p

EDIT: JavaScript would be very difficult to implement in this case. JavaScript is a client side scripting language, which allows you to execute some scripts in the client's browser AFTER the page has been processed and sent through. You need a server side solution to determine the size of the database file, seeing as the web application will (presumably) be hosted on a server that has access to the database file.
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X