how to get number of files in a folder

S

sasikumar

i have created a new folder inside project(say update for storing
update files for software)
how can i get total number of files in that folder.what will be full
path for accessing that folder.(path compatibile for use in system.io)
 
N

Nathan Sokalski

To get the number of files in a folder, use the following:


Dim filecount as Integer =
System.IO.Directory.GetFiles(Server.MapPath("./")).Length()


This code gets the number of files in the current directory. Server.MapPath
takes one parameter which is a String that is the relative path to the
desired directory and returns the complete path on the server. To get the
number of files in a different directory, simply change the parameter to
something like:


Dim filecount as Integer =
System.IO.Directory.GetFiles(Server.MapPath("myfiles/")).Length()


Because the parameter is a relative path, you can also use "../" to go up
one directory. If you have any questions, feel free to ask or see the
documentation. Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top