我想计算文件夹中的图像数量,但它会产生以下错误:
Could not find a part of the path 'c:\Content\slideshow\images\image\'.
所有图像都位于项目的文件夹中。位于一个Content/slideshow/images/image
这是我的代码:
<%
string dir = @"/Content/slideshow/images/image";
string[] files;
int numFiles;
files = System.IO.Directory.GetFiles(dir);
numFiles = files.Length;
Response.Write("num ber of images :" + numFiles);
%>
“找不到路径的一部分
'c:\Content\slideshow\images\image\'"
很简单,意味着该文件夹不存在。如果您想使用相对路径,可以执行以下操作。
Server.MapPath("~/{RelativePathHere})
编辑:回应您的评论。您将需要循环遍历文件并检查每个文件的文件扩展名(保留您自己的计数)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)