473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Count the number of hidden files and directories

Is there a way to determine the number of hidden files/directories within a
directory? This is what I’m doing now:

System.IO.DirectoryInfo rootPath;
System.IO.FileSystemInfo[] dirs, files;
int numOfDirs = 0, numOfFiles = 0;

di = new System.IO.DirectoryInfo(“blah”);
dirs = rootPath.GetDirectories();
files = rootPath.GetFiles();

for (int i=0; i<dirs.Length; i++)
numOfDirs += ((dirs[i].Attributes & System.IO.FileAttributes.Hidden) ==
System.IO.FileAttributes.Hidden) ? 0 : 1;

for (int i=0; i<files.Length; i++)
numOfFiles += ((files[i].Attributes & System.IO.FileAttributes.Hidden) ==
System.IO.FileAttributes.Hidden) ? 0 : 1;

It seems like there must be a better way?
This can’t be very efficient.

Thanks,

Dale
Nov 16 '05 #1
3 4958
Hi Dale,

Regarding on the problem you mentioned ,I'm finding proper resource to
assist you and will reply as soon as possible. Thanks for your
understanding.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 16 '05 #2
Hi Dale,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the count for hidden
files and directorys under certain directory. If there is any
misunderstanding, please feel free to let me know.

As far as I know, there isn't a method in current .NET framework for us to
get the count directly. In my opinion, the code you have provided is quite
good. I will do this also in this case.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3
Kevin,

You understand perfectly. It looks like I am already using the best method
available.

Thanks for your time.

Dale
Nov 16 '05 #4

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

Similar topics

1
by: Lothar Scholz | last post by:
Hello, i know that this is not a python but a FTP protocol question but maybe someone in this newsgroup could help me. I use the standard ftplib.FTP class and get the listing wia...
2
by: Darren | last post by:
Hi Group, Any ideas how to check for files in a directory, to see if any are of the same prefix, and make a count of them. I have a round 100 files, the filename is made up of an engineer...
4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
4
by: laredotornado | last post by:
Hello, Using PHP 4, is there a fucntion that counts the files in a given directory? You can assume there are no sub-directories within this directory and hence, no files within the...
2
by: MichiMichi | last post by:
My asp.net application has a directory which is filled up with over 17 files (email) a second. After a while this sums up into a huge amount of files. I usually count files with the GETFILES...
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: googletired | last post by:
Ok, I need to be able to count the # of items for each category and have it display. So say i have a left menu that displays that category name for cat in the current issue.xml for instance...
1
by: briggs | last post by:
Hi All, I need to take the count of txt and bak files present in all the directory.for eg if we assume there are two directoies say(test1, test2), I need to collect the count(of txt and bak files)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.