Search Tools Links Login

Disk Space Usage


This code will tell you how much disk space on your server you're using

Original Author: Agnus Imonar

Inputs

Noke

Assumptions

Just paste the code into an .asp page on the root dir of your web

Returns

The disk space you're using on your server

Code






New Page 1


<%

'Capture the name of the page as well as directory structure 

script_name=request.servervariables("script_name")



'Split the directory tree into an arry by /

split_name=split(script_name,"/")



' Sets the number of directory levels down

num_directory=ubound(split_name)-1



%>

<html>

<title>CodeAve.com(Directory Size)</title>

<body bgcolor="#FFFFFF">



<table align="center">

<tr>

<td width=150>

<b>Directory</b>

</td>

<td width=150>

<b>Megabytes</b>

</td>

<td width=150>

<b>Kilobytes</b>

</td>

<td width=150>

<b>Bytes</b>

</td>

</tr>

<%

' Create a file system object to read all the directories

' beneath the current directory split_name(num_directory)

' You can hard code the directory name if you like

set directory=server.createobject("scripting.filesystemobject")

set allfiles=directory.getfolder(server.mappath("../"& split_name(num_directory)& "/"))



' Lists all the files found in the directory

for each directory in allFiles.subfolders

' Removes certain MSFrontPage was directories 

if right(directory.Name,3) <> "cnf" then 

'Adds the folder sizes up for a total

total_size=total_size + directory.size %>



<tr>

<td width=150>

<%= directory.name %>

</td>

<td width=150><%= formatnumber((directory.size/1024/1024),2) %></td>

<td width=150><%= formatnumber((directory.size/1024),0) %></td> 

<td width=150><%= formatnumber(directory.size,0) %></td> 

</tr>

<% end if 'end check for FrontPage directories 

next 'end of the for next loop %>

<tr>

<td width=150><b>Total</b></td>

<td width=150><%= formatnumber((total_size/1024/1024),2) %></td>

<td width=150><%= formatnumber((total_size/1024),0) %></td> 

<td width=150><%= formatnumber(total_size,0) %></td> 

</tr>

</table>



</body>

</html>



About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 87 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.