Solved

WIN32 API function to get Disk free space..

Posted on 2003-11-06
5
794 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
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…

730 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