473,387 Members | 1,534 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,387 software developers and data experts.

Counting files in directory

I have an ASP.Net web site that does some file system folder access. One of
the things I am doing is counting the # of files in a passed directory to
determine if I show or hide something on the page. My problem is that I
want to ignore hidden files in the count but I can't find a way to do this.
Below is my code. Can someone let me know if this is possible and how to do
it? Thanks.

David

Public Shared Function FilesInPath(ByVal strPhyPath As String) As Integer

Dim intFiles As Integer = My.Computer.FileSystem.GetFiles(strPhyPath).Count

FilesInPath = intFiles

End Function
Nov 19 '07 #1
2 1774
to figure out hidden versus non-hidden files, you have to look at the
attributes of each file, which means you will have to loop through all files
in the directory to examine them.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"David C" <dl*****@lifetimeinc.comwrote in message
news:el**************@TK2MSFTNGP03.phx.gbl...
>I have an ASP.Net web site that does some file system folder access. One
of the things I am doing is counting the # of files in a passed directory
to determine if I show or hide something on the page. My problem is that I
want to ignore hidden files in the count but I can't find a way to do this.
Below is my code. Can someone let me know if this is possible and how to
do it? Thanks.

David

Public Shared Function FilesInPath(ByVal strPhyPath As String) As Integer

Dim intFiles As Integer =
My.Computer.FileSystem.GetFiles(strPhyPath).Count

FilesInPath = intFiles

End Function


Nov 19 '07 #2
I was afraid of that. It would be nice to have something like the
"wildcard" in file search to look for attributes. Thanks.

David
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:OD**************@TK2MSFTNGP06.phx.gbl...
to figure out hidden versus non-hidden files, you have to look at the
attributes of each file, which means you will have to loop through all
files in the directory to examine them.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
"David C" <dl*****@lifetimeinc.comwrote in message
news:el**************@TK2MSFTNGP03.phx.gbl...
>>I have an ASP.Net web site that does some file system folder access. One
of the things I am doing is counting the # of files in a passed directory
to determine if I show or hide something on the page. My problem is that
I want to ignore hidden files in the count but I can't find a way to do
this. Below is my code. Can someone let me know if this is possible and
how to do it? Thanks.

David

Public Shared Function FilesInPath(ByVal strPhyPath As String) As Integer

Dim intFiles As Integer =
My.Computer.FileSystem.GetFiles(strPhyPath).Cou nt

FilesInPath = intFiles

End Function



Nov 19 '07 #3

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

Similar topics

3
by: Ron Nolan | last post by:
Re: Access 2000 How can I loop through a folder on the user's hard drive, and check to see if it is an .mdb file. If it is an .mdb, do some stuff, else go to the next filename? Can this be...
18
by: Conrad F | last post by:
Hello all, I am waiting for receipt of files in a directory. I use the FileSystemWatcher to detect when files arrive in said folder. I need to read the data from these files ASAP but the files...
5
by: Anders K. Jacobsen [DK] | last post by:
Hi We have a rather large asp.net project with serveral utility projects (written in C#). Is there at tool out there which can give an estimate of the total amount of code lines all projects...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
14
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
4
by: frizzle | last post by:
Hi there, I have a function to create an array of all files in a certain folder, so i can display the structure. The actual function is below the message, as is an example of its output. As...
0
by: blade4383 | last post by:
Hello everyone, I want some ideas on script that is event triggered. Like when a new file is added to a directory. so before the file is saved in the directory the GID should be changed to a...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
15
by: ghostxx | last post by:
Alright well i've been working at this for a ridiculously longer amount of time than i think i should have been, so i finally gave up and that's why im here. I program in C++ and hardly do any...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.