How to count files using

Posted on 2006-07-23
Last Modified: 2010-05-18

Using ASP.NET I want to count the number of files in a folder.

I've got this so far....(I'm moving email file from one folder to another....I would like to count the remaining files)
<%@ Import Namespace="System.IO" %>
<%@ Import namespace="System.Collections" %>
For Each s in Directory.GetFiles(sourcePath, "*.eml")
          File.Move(sourcePathFileName, destinationPathFileName)


---- Mike

Question by:MikeCombe
  • 2
LVL 10

Accepted Solution

orbulat earned 500 total points
ID: 17165319
how about "Directory.GetFiles().Length "?

Expert Comment

ID: 17165378
orbulat is absolutely correct, just a small insertion..

        Label1.Text = Directory.GetFiles(sourcePath, "*.eml").Length

Assumed a label exist and assigning the return value to label.text

Credit goes to orbulat.


Author Comment

ID: 17165421
Thanks to BOTH of you.....very helpful !

--- Mike
LVL 10

Expert Comment

ID: 17165560
thanks :-)

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now