判断远程文件是否存在

        private bool RemoteFileExists(string fileUrl)
        {
            
try
            {
                HttpWebRequest re 
= (HttpWebRequest)WebRequest.Create(fileUrl);
                HttpWebResponse res 
= (HttpWebResponse)re.GetResponse();
                
if (res.ContentLength != 0)
                {
                    
//MessageBox.Show("文件存在");
                    return true;
                }
            }
            
catch (Exception)
            {
                
//MessageBox.Show("无此文件");
                return false;
            }
            
return false;
        }
posted @ 2009-11-05 11:23  韩天伟  阅读(2249)  评论(1编辑  收藏  举报