RE: CD Rom used,free and capacity
v-jetan_at_online.microsoft.com
Date: 03/10/04
- Next message: v-jetan_at_online.microsoft.com: "RE: Any event?"
- Previous message: Grey: "Populate to IE"
- In reply to: John Hoffman: "CD Rom used,free and capacity"
- Next in thread: John Hoffman: "RE: CD Rom used,free and capacity"
- Reply: John Hoffman: "RE: CD Rom used,free and capacity"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Mar 2004 08:19:05 GMT
Hi John,
Thank you for posting in the community!
Based on my understanding, you want to retrieve the CDRom's used,free and
capacity space.
========================
You may use WMI to get this done.
You can use Win32_LogicalDisk Wmi class. For this class, you can use Size
property to get the capacity of the disk, use the FreeSpace property to get
the freespace. Then, the used space can be calculate from Size- FreeSpace.
Do like this:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select *
from Win32_LogicalDisk WHERE DriveType =4");
foreach(ManagementObject mo in searcher.Get())
{
MessageBox.Show( "FreeSpace: "+mo["FreeSpace"].ToString());
MessageBox.Show( "CapacitySpace: "+mo["Size"].ToString());
uint64 usedspace= (uint64)mo["Size"]-
(uint64)mo["FreeSpace"];
MessageBox.Show( "UsedSpace: "+ usedspace.ToString());
}
Also, you may COM interop the Scripting FileSystemObject to get this done:
Scripting.FileSystemObject FSO = new Scripting.FileSystemObjectClass();
string [] logDrives=System.IO.Directory.GetLogicalDrives();
for ( int i =0;i< logDrives.GetUpperBound(0)+1;i++)
{
Scripting.Drive thisdrive=FSO.GetDrive(logDrives[i]);
if (thisdrive.DriveType==Scripting.DriveTypeConst.CDRom )
{
MessageBox.Show(thisdrive.Path+" FreeSpace: "+thisdrive.FreeSpace );
MessageBox.Show(thisdrive.Path+" TotalSize: "+thisdrive.TotalSize );
}
}
================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
- Next message: v-jetan_at_online.microsoft.com: "RE: Any event?"
- Previous message: Grey: "Populate to IE"
- In reply to: John Hoffman: "CD Rom used,free and capacity"
- Next in thread: John Hoffman: "RE: CD Rom used,free and capacity"
- Reply: John Hoffman: "RE: CD Rom used,free and capacity"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|