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

How to check if a directory is empty?

Is there a quick way to determine if a directory is empty.
Directory.Getfiles() doesn't tell me how many files without having to loop
thru the list.

Thanks

Bill
Nov 21 '05 #1
3 25459
directory.getfiles().count ?

"Bill nguyen" <bi*****************@jaco.com> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
Is there a quick way to determine if a directory is empty.
Directory.Getfiles() doesn't tell me how many files without having to loop
thru the list.

Thanks

Bill

Nov 21 '05 #2
"Bill nguyen" <bi*****************@jaco.com> schrieb:
Is there a quick way to determine if a directory is empty.
Directory.Getfiles() doesn't tell me how many files without having to loop
thru the list.


\\\
Dim FileCount As Integer = Directory.GetFiles("C:\Foo").Length
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
I'll try .Length . I couldn't find .Count with Getfiles()

Thanks both Brian & Herfried for your prompt response.

Bill
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ek**************@TK2MSFTNGP14.phx.gbl...
"Bill nguyen" <bi*****************@jaco.com> schrieb:
Is there a quick way to determine if a directory is empty.
Directory.Getfiles() doesn't tell me how many files without having to
loop thru the list.


\\\
Dim FileCount As Integer = Directory.GetFiles("C:\Foo").Length
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

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

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
1
by: Dennis | last post by:
Hi, I am wondering that the Application Name in Virtual Directory is compulsory be non-empty field when configuring Virtual Directory for ASP.NET application? I realized some of my ASP.NET...
5
by: Marcia Hon | last post by:
Hi, I would like to know how the following may be accomplished in C: 1. Check if a directory is empty. 2. Empty the directory. Please if you know how could you state what statements in C...
2
by: DC Gringo | last post by:
How do I check to see if a file directory is empty? If (System.IO.File.Exists(*.*)) Then pnlMyPanel.Visible = True End If -- _____ DC G
7
by: Anil Gupte | last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu2Exit.Click Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName) ...
16
by: mtuller | last post by:
I am creating a page for nomination and want to let the information pass if any field are filled out, but if none are filled out, a message will appear. I can't get the check to happen on multiple...
5
by: Gordon | last post by:
I'm trying to remove a directory and all its contents from within a script. I wrote a recursive function to take care of it, but when I run it I get random "Directory not empty" error messages. ...
2
by: lairpr74 | last post by:
I am trying to update the managers name in active directory with an application I got that updates active directory. I been strugling with this for a few weeks now and couldn't find the best way...
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...
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
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,...

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.