页面导航: 首页网络编程ASP.NET实用技巧 → 正文内容 asp.net检测图片是否存在

asp.net(c#)判断远程图片是否存在

发布:dxy 字体:[增加 减小] 类型:转载
不错的应用,大家可以拓展到,判断远程文件是否存在等功能

private int GetUrlError(string curl)
{
int num = 200;
if(this.method==1)
{
HttpWebRequest request=(HttpWebRequest) WebRequest.Create(new Uri(curl));
ServicePointManager.Expect100Continue=false;
try
{
((HttpWebResponse)request.GetResponse()).Close();
}
catch(WebException exception)
{
if(exception.Status != WebExceptionStatus.ProtocolError)
{
return num;
}
if(exception.Message.IndexOf( "500 ")>0)
{
return 500;
}
if(exception.Message.IndexOf( "401 ")>0)
{
return 401;
}
if(exception.Message.IndexOf("404")>0)
{
num=404;
}
}
return num;
}
}
Tags:c# 远程图片
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行