判断远程的资源是否存在

#region 判断远程的资源文件是否存在

        public bool RemoteFileExists(string fileUrl)
        {
            bool result = false;//下载结果
            WebResponse response = null;
            try
            {
                WebRequest req = WebRequest.Create(fileUrl);
                response = req.GetResponse();
                result = response == null ? false : true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            finally
            {
                if (response != null)
                {
                    response.Close(); 
                }
            }
            return result;

        }

        #endregion


更多相关知识参考:http://space.itpub.net/12639172/viewspace-497710

你可能感兴趣的:(java,.net)