473,809 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByV al strPhyPath As String) As Integer

Dim intFiles As Integer = My.Computer.Fil eSystem.GetFile s(strPhyPath).C ount

FilesInPath = intFiles

End Function
Nov 19 '07 #1
2 1794
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*****@lifeti meinc.comwrote in message
news:el******** ******@TK2MSFTN GP03.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(ByV al strPhyPath As String) As Integer

Dim intFiles As Integer =
My.Computer.Fil eSystem.GetFile s(strPhyPath).C ount

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.netNoS pamMwrote in
message news:OD******** ******@TK2MSFTN GP06.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*****@lifeti meinc.comwrote in message
news:el******** ******@TK2MSFTN GP03.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(ByV al strPhyPath As String) As Integer

Dim intFiles As Integer =
My.Computer.Fi leSystem.GetFil es(strPhyPath). Count

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
5729
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 done without using recordsets? Thanks,
18
20194
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 are created and detected before writing completes and so I cannot read them until the file handle used in their creation has been released. This would be easy to get around with file renaming or other file locking mechanisms which I could use...
5
2850
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 results in? thanks in regads Anders
1
6934
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 with uploaded MS WORD .doc files. Using code like that below: strLine = sr.ReadLine While Not IsNothing(strLine) 'Not eof If Trim(strLine) <> "" Then 'Not blank
14
2094
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
1584
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 one can see, the filesize is also stored in the array (more info will be added, like filemtime), what i need is to sum all bytes per folder.
0
1406
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 particular value and then after say 1 or 2 mins the files ownership should be changed to the normal UID and GID. cheers
15
1425
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
24817
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 python.. ever. So i need a little help and hope you all will be kind enough to throw some knowledge my way. What i need to do, is count the files in the directory that my python script is currently in. It needs to be able to list ONLY the files, and NO...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10633
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4331
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 we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.