How to count files using asp.net

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

MikeCombeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
orbulatConnect With a Mentor Commented:
how about "Directory.GetFiles().Length "?
0
 
irps20001Commented:
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
 
MikeCombeAuthor Commented:
Thanks to BOTH of you.....very helpful !

--- Mike
0
 
orbulatCommented:
thanks :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.