MagicDisk Object  

In just couple lines of code you can get all disk information that you need, such as free space and disk total capacity. It even calculates used and free space percent. Based on this information you can allow or disallow some user actions, but you may be sure that your application or server will not crash because of insufficient disk space.

 
 

Methods

  GetDisks Method
SetDisk Method
GetLastErrorNbr Method
GetLastErrorDscr Method

 

Properties

  GetTotalSpace Property
GetFreeSpace Property
GetFreePercent Property
GetUsedPercent Property

 

Working with MagicDisk

 

GetDisks Method

Return information about disks and their types.
Return Value: Nonzero if successful; otherwise 0.
Syntax: object.GetDisks(varDisks, varTypes)
varDisks - returns the drive's letters of physical disk drives and network share;
varTypes - returns a value indicating the types of disk drives;

SetDisk Method

Syntax: object.SetDisk(varDisk)
The vardisk argument is a value equal disk letter and ":", "C:" for example.
GetLastErrorNbr Method
Returns number of a last error.
Syntax: object.GetLastErrorNbr
GetLastErrorDscr Method
Returns description of a last error.
Syntax: object.GetLastErrorDscr
GetTotalSpace Property
Returns the total space, in bytes, of the specified drive or network share.
Syntax: object.GetTotalSpace
GetFreeSpace Property
Returns the amount of space available to a user on the specified drive.
Syntax: object.GetFreeSpace
GetFreePercent Property
Returns the free space percent of the specified drive or network share.
Syntax: object.GetFreePercent
GetUsedPercent Property
Returns the used space percent of the specified drive or network share.
Syntax: object.GetFreeSpace

Example:

To call the MagicDisk Object from an Active Server Page, you will need to create the object using the following code:

<%
Dim myTotalSpace
Dim myFreeSpace
Dim myFreePercent
Dim myUsedPercent

Set MyObj=Server.CreateObject("MagicBundle.MagicDisk")
Call MyObj.SetDisk ("c:")
myTotalSpace=MyObj.GetTotalSpace
myFreeSpace=myobj.GetFreeSpace
myFreePercent=myobj.GetFreePercent
myUsedPercent=myobj.GetUsedPercent
response.write ("Total Disk Space: " & myTotalSpace & " bytes <br>")
response.write("Free Space: " & myFreeSpace & " bytes <br>")
response.write("Free Space is: " & myFreePercent & "% <br>")
response.write("Used Space is: " & myUsedPercent & "% <br>")
if myFreePercent < 20 then
    response.write "<b>You have left less then 20% of disk space</b>"
end if
%>

Remember to enclose the code within <% %> brackets.

top


Home | FAQ | News | How to buy | Contacts | ASP MagicPerf Component | ASP MagicShell Component