shell怎么判断文件是否存在 c#判断远程文件是否存在
c#判断远程文件是否存在

// : public static bool IsExist(string uri) { HttpWebRequest req = null; HttpWebResponse res = null; try { req = (HttpWebRequest)WebRequest Create(uri); req Method = HEAD ; req Timeout = ; 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; } } }
// :
private bool UrlExistsUsingXmlHttp(string url) { //注意 此方法需要引用Msxml dll MSXML XMLHTTP _xml(); _xml open( HEAD url false null null); _xml send( ); return (_xml status == ); }
lishixinzhi/Article/program/net/201311/11555