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

      

  • 相关阅读:
    全排列
    RazorPages中的绑定
    SQL Server安装步骤
    2020-2021---开发工作总述
    C#.NET编程的特点
    VS自带Git的使用
    从apk反编译出.java文件
    基于页面的编程模型+关于设计的表达
    XtraReport注意事项
    Android总结
  • 原文地址:https://www.cnblogs.com/professional-NET/p/4662869.html
Copyright © 2020-2023  润新知