VB icon

Disk Space Usage

Submitted on: 1/5/2015 8:14:00 AM
By: Agnus Imonar (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages), HTML, VbScript (browser/client side)
Views: 1285
     This code will tell you how much disk space on your server you're using
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
' Name: Disk Space Usage
' Description:This code will tell you how much disk space on your server you're using
' By: Agnus Imonar (from psc cd)
' Inputs:Noke
' Returns:The disk space you're using on your server
' Assumes:Just paste the code into an .asp page on the root dir of your web

<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META name="GENERATOR" content="Microsoft FrontPage 4.0">
<META name="ProgId" content="FrontPage.Editor.Document">
<TITLE>New Page 1</TITLE>
'Capture the name of the page as well as directory structure <BR>
'Split the directory tree into an arry by /<BR>
' Sets the number of directory levels down<BR>
<title>CodeAve.com(Directory Size)</title><BR>
<body bgcolor="#FFFFFF"><BR>
<table align="center"><BR>
<td width=150><BR>
<td width=150><BR>
<td width=150><BR>
<td width=150><BR>
' Create a file system object to read all the directories<BR>
' beneath the current directory split_name(num_directory)<BR>
' You can hard code the directory name if you like<BR>
set directory=server.createobject("scripting.filesystemobject")<BR>
set allfiles=directory.getfolder(server.mappath("../"& split_name(num_directory)& "/"))<BR>
' Lists all the files found in the directory<BR>
for each directory in allFiles.subfolders<BR>
' Removes certain MSFrontPage was directories <BR>
if right(directory.Name,3) <> "cnf" then <BR>
'Adds the folder sizes up for a total<BR>
total_size=total_size + directory.size %><BR>
<td width=150><BR>
<%= directory.name %><BR>
<td width=150><%= formatnumber((directory.size/1024/1024),2) %></td><BR>
<td width=150><%= formatnumber((directory.size/1024),0) %></td> <BR>
<td width=150><%= formatnumber(directory.size,0) %></td> <BR>
<% end if 'end check for FrontPage directories <BR>
next 'end of the for next loop %><BR>
<td width=150><b>Total</b></td><BR>
<td width=150><%= formatnumber((total_size/1024/1024),2) %></td><BR>
<td width=150><%= formatnumber((total_size/1024),0) %></td> <BR>
<td width=150><%= formatnumber(total_size,0) %></td> <BR>

Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.