|
CodeAve.com - ASP - Server Variables | |||
|
|
|||
| Disk Space Usage | ||||
|
|
||||
<% '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>
|
||||
|
|
||||