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; }

  

相关文章:

  • 2022-02-17
  • 2022-12-23
  • 2022-02-02
  • 2021-09-26
  • 2022-12-23
  • 2021-08-14
  • 2021-12-31
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案