zoukankan      html  css  js  c++  java
  • C#中判断服务器图片是否存在

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

      

  • 相关阅读:
    wireshark安装
    高效使用搜索引擎
    MFC 网络编程 -- 总结
    MFC Grid control 2.27
    A Popup Progress Window
    Showing progress bar in a status bar pane
    Progress Control with Text
    Report List Controls
    第三方
    CBarChart柱形图类
  • 原文地址:https://www.cnblogs.com/professional-NET/p/4662869.html
Copyright © 2011-2022 走看看