Solved

How to count files using asp.net

Posted on 2006-07-23
4
1,504 Views
Last Modified: 2010-05-18
Hello,

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)
Next

Thanks,

---- Mike

0
Comment
Question by:MikeCombe
  • 2
4 Comments
 
LVL 10

Accepted Solution

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

Expert Comment

by:irps20001
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.

0
 

Author Comment

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

--- Mike
0
 
LVL 10

Expert Comment

by:orbulat
ID: 17165560
thanks :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

18 Experts available now in Live!

Get 1:1 Help Now