Solved

WIN32 API function to get Disk free space..

Posted on 2003-11-06
5
801 Views
Last Modified: 2012-08-13
Hi,

  Any way of finding free disk space in pel WIN32 API..???

-Prash
0
Comment
Question by:prashanthgn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Expert Comment

by:jt401
ID: 9694992
you can use Win32::DriveInfo  -

use Win32::DriveInfo;

$TotalNumberOfFreeBytes = (Win32::DriveInfo::DriveSpace('c:'))[6];
0
 

Author Comment

by:prashanthgn
ID: 9699234
Thanx for the help,

I have 2 more questions,

1.
How to get the number of files and dirs (including files and dirs in the sub dirs).
I tried to use

      use File::Find;
               find(\&Getfiles, "c:\\temp");
               sub Getfiles {
                       ### count files and dirs here....
      }

But this takes a lot of time if the dir contains more number of files ....

Is there any of finding it more quickly....

2.
Is there any function to check if any specified extension  file exists in a dir..??


Thanx in advance
0
 
LVL 1

Accepted Solution

by:
jt401 earned 50 total points
ID: 9702932
It's just natural that it will take longer to do a recursive search if there are many files.. I don't know of any way to speed this up.
If you want to specify several top level directories to search, you can pass an array of dir paths to the sub:

@dirs = qw|c:/temp c:/winnt/system32|;
find(\&Getfiles, @dirs);

# this will print only txt and doc files.
# if you only want the filename and not the complete path
#  use $_ in place of $File::Find::name

sub Getfiles {
   return unless -f $File::Find::name;
   /(\.txt|\.doc)$/i && print "$File::Find::name\n";
}
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10049579
Nothing has happened on this question in more than 8 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by jt401.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question