判断远程文件是否存在
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;
}
{
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;
}