C#에서 서버 이미지 존재 여부 판단

1344 단어
     public int num = 0;
/// /// /// 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("alert(' , , !');");} if (exception.Message.IndexOf("401 ") > 0){ Response.Write("alert(' , !');");} if (exception.Message.IndexOf("404")> 0){ return num; } } num++; } return num; }

  
다음으로 전송:https://www.cnblogs.com/professional-NET/p/4662869.html

좋은 웹페이지 즐겨찾기