如何检查ASP.Net中的Web位置(在不同的Web应用程序中,但是同一个Web服务器)中的文件退出,目前我这样做。有没有更好的方法来做到这一点?如何检查使用C#查看远程文件是否存在?
using (WebClient client = new WebClient())
{
try
{
Stream stream = client.OpenRead("http://localhost/images/myimage.jpg");
if (stream != null)
{
//exists
}
}
catch
{
//Not exists
}
}
添加了对异常的评论。 – 2009-09-18 10:03:40