- #region 判断远程文件是否存在
- /// <summary>
- /// 判断远程文件是否存在
- /// </summary>
- /// <param name="fileUrl"></param>
- /// <returns></returns>
- public static bool RemoteFileExists(string fileUrl)
- {
- HttpWebRequest re = null;
- HttpWebResponse res = null;
- try
- {
- re = (HttpWebRequest)WebRequest.Create(fileUrl);
- res = (HttpWebResponse)re.GetResponse();
- if (res.ContentLength != 0)
- {
- //MessageBox.Show("文件存在");
- return true;
- }
- }
- catch (Exception)
- {
- //MessageBox.Show("无此文件");
- return false;
- }
- finally
- {
- if (re != null)
- {
- re.Abort();//销毁关闭连接
- }
- if (res != null)
- {
- res.Close();//销毁关闭响应
- }
- }
- return false;
- }
- #endregion

![[手游] 三网H5小游戏【少年仙路】WIN系服务端+Linux手工服务端+详细搭建教程](https://cdn.jxasp.com:9143/image/20260615/136BC33AA47EB0D84E878835A8B38FDB.png)

















