public int num = 0;
/// <summary>
/// 判断服务器路径中的图片文件是否存在存在则累加统计
/// </summary>
private int GetAcount(string name)
{
for (int i = 1; i < i + 1; i++)
{
string url = "http://IP/Image/" + name + "/" + name + i + ".jpg";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(url));
ServicePointManager.Expect100Continue = false;
try
{
((HttpWebResponse)request.GetResponse()).Close();
}
catch (WebException exception)
{
if (exception.Status != WebExceptionStatus.ProtocolError){
num++;
}
if (exception.Message.IndexOf("500 ") > 0){
Response.Write("<script>alert('服务器内部错误,无法完成请求,请联系管理 员!');</script>");}
if (exception.Message.IndexOf("401 ") > 0){
Response.Write("<script>alert('需要身份认证,你没有权限!');</script>");}
if (exception.Message.IndexOf("404")> 0){
return num;
}
}
num++;
}
return num;
}