简体   繁体   中英

How to figure out number of files in specific folder on server?

I have been trying to find a way to get the count of how many files are in a folder called "images", which is in a folder I am already in.

This is the code I have been trying but I have been getting an error message:

Code:

count = System.IO.Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath("/images"), 
"(asterisk symbol).(asterisk symbol)").Count()

The error message says it can't find the path.

When debugging a problem, break the line of code in to smaller pieces to make it earier to see. I would first print out the value of System.Web.HttpContext.Current.Server.MapPath("/images") . Then see if that's a real folder. .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM