需要用server.mappath(path)吧,然后再用File.Exists(server.mappath(path))去判断吧。

解决方案 »

  1.   

    是的,File.Exists 只能判断本地的文件存在不存在,不能判断网络上的文件在不在。即使在你的asp.net程序中用File.Exists(server.mappath(path)),也只是判断服务器的File在不在,而不是本地客户端。
      

  2.   


                HttpWebResponse webResponse;
                try
                {
                    String url = "Your Url";
                    HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;                webResponse = webRequest.GetResponse() as HttpWebResponse;            }
                catch (WebException webEx)
                {
                    webResponse = webEx.Response as HttpWebResponse;
                    if (webResponse.StatusCode == HttpStatusCode.NotFound)
                    {
                        Console.WriteLine("请求的文件不存在!");
                    }
                }
      

  3.   

    没听太懂,版主说不能判断网络上的文件在不在,后面又说也只能判断服务器的File在不在
    --!
      

  4.   

    没听太懂,版主说不能判断网络上的文件在不在,后面又说也只能判断服务器的File在不在
    --!
    1、如果你是c/s程序,比如winform,那么file.exists只能判断本地的文件有没有
    2、如果你是b/s程序,判断的是服务器本地磁盘的文件有没有