c#检查网络文件是否存在
public bool IsExist(string uri) { HttpWebRequest req = null; HttpWebResponse res = null; try { req = (HttpWebRequest)WebRequest.Create(uri); req.Method = "HEAD"; req.Timeout = 100; res = (HttpWebResponse)req.GetResponse(); return (res.StatusCode == HttpStatusCode.OK); } catch { return false; } finally { if (res != null) { res.Close(); res = null; } if (req != null) { req.Abort(); req = null; } } }