C# 判断远程文件是否存在
/// <summary> /// 判断远程文件是否存在 /// </summary> /// <param name="url">url地址</param> /// <returns></returns> public bool FileExists(string url) { //ture为存在,false为不存在 bool result = false; WebResponse response = null; try { WebRequest req = WebRequest.Create(url); response = req.GetResponse(); result = response == null ? false : true; } catch (Exception ex) { result = false; } finally { if (response != null) { response.Close(); } } return result; }