Just for the record, there is also Win32::DriveInfo::DriveSpace().

Kev.

------------------------------

Message: 14
Date: Wed, 25 Aug 2004 12:34:03 -0500
From: "Dirk Bremer \(NISC\)" <[EMAIL PROTECTED]>
Subject: Re: Determining Available Disk Space
To: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain;       charset="iso-8859-1"

Thanks to all who responded. I ended up with this to produce my desired
result:

    # Construct a WMI object instance.
    my $WMI = Win32::OLE->GetObject("winmgmts:\\\\mailcd\\root\\cimv2");

    # Query for the D-drive information.
    my $Collection = $WMI->ExecQuery("SELECT * FROM Win32_LogicalDisk where
DeviceID = 'D:'");

    # Calculate the free-space in megabytes.
    my $Space;
    foreach my $Obj (in $Collection) {$Space = int($Obj->{FreeSpace})}

Note the adjustment that I made to the SELECT statement to query only the
single specific drive. I will use the raw free space number to compare
against the raw size of the current file that will be copied to determine if
there is enough free disk space to perform the copy operation.

As an aside, is there a way to directly access the returned hash elements
rather than using the following loop?

    foreach my $Obj (in $Collection) {$Space = int($Obj->{FreeSpace})}


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

This e-mail is confidential and may contain legally privileged information.  You 
should not disclose its contents to any other person.  If you are not the intended 
recipient, please notify the sender immediately.

Whilst the Council has taken every reasonable precaution to minimise the risk of 
computer software viruses, it cannot accept liability for any damage which you may 
sustain as a result of such viruses.  You should carry out your own virus checks 
before opening the e-mail (and/or any attachments).

Unless expressly stated otherwise, the contents of this e-mail represent only the 
views of the sender and do not impose any legal obligation upon the Council or commit 
the Council to any course of action.


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to