如何檢查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