473,473 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Number of files inside a directory (including all subdirectories)

jj
Hi folks:

I can get the list of files in a certain directory by using
Directory.GetFiles("c:\temp").
But I want to get the number of files (ex. 20) within a directory including
all subdirectories. I don't want to scan through the whole recursively and
count. Is there a way?

Thanks
John
Nov 16 '05 #1
1 9249
John,

You should be able to make a call to FindFirstFileEx, FindNextFile, etc,
etc through the P/Invoke layer. Just set the filter to "*" and you should
be able to get a complete count.

You might also be able to do a select from the WMI provider for the
windows file system, but this could really hit you performance wise.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jj" <yh*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi folks:

I can get the list of files in a certain directory by using
Directory.GetFiles("c:\temp").
But I want to get the number of files (ex. 20) within a directory
including
all subdirectories. I don't want to scan through the whole recursively and
count. Is there a way?

Thanks
John

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David T. Ashley | last post by:
Hi, PHP allows the "library" which can contain an arbitrary number of include files. Can I put all the include files right in this directory, or should I create subdirectories? My question...
5
by: Anand K Rayudu | last post by:
Hi all, I am trying to find a way to get the files recursively in a given directory, The following code is failing, can some one please suggest what could be problem here from os import...
2
by: Arjen | last post by:
Hello, I want to make a command line application that search for *.htm* files inside directories and subdirectories. 1. How can I save all the *.htm* files inside directories and...
31
by: Joseph Wakeling | last post by:
Hello all, I'm writing some programs that will be using modules from the GNU Scientific Library (GSL). Include commands within the GSL modules have commands such as, #include...
6
by: learnerofpython | last post by:
hi! i have a directory structure(can be of any type) I want to search for the files present in it and extract the names of those files(file can be of any format e.g .txt/.c/.py) How can...
2
by: Alex | last post by:
Hello, I'm creating a program to parse a directory and all files within that directory (including subdirectories), but 'directoryinfo' only parses the current directory. Is it possible to have...
8
by: theCancerus | last post by:
Hi All, I am not sure if this is the right place to ask this question but i am very sure you may have faced this problem, i have already found some post related to this but not the answer i am...
2
by: dj | last post by:
Hello All, I am attempting to us os.walk to populate two lists with values from a directory. The first list contains all the files in the directory and subdirectories. The second list contains...
4
by: supriyamk | last post by:
Hi, I am trying to search a directory for subdirectories, recreate the subdirectories elsewhere and copy only certain files from current subdirectory to new subdirectory. In other words i am...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.