Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1512
  • Last Modified:

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

0
MikeCombe
Asked:
MikeCombe
  • 2
1 Solution
 
orbulatCommented:
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now