如题 
第一 如何判断 http://www.xxxx.com/aaa.rar  文件是否存在 
第二 如果存在 怎么获取这个文件的尺寸大小. 网络

解决方案 »

  1.   

    webrequest,然后获得一个response。response.ContentLength
      

  2.   

    参考:
    http://www.cnblogs.com/wenbinliu/archive/2013/02/01/2889002.html
      

  3.   


     WebRequest req = WebRequest.Create(fileUrl);
     WebResponse  response = req.GetResponse();
    // 获取文件大小
    int length =reponse.ContentLength;
    如果返回的文件大小为0 也就代表文件不存在了
      

  4.   

    文件不存在,会抛出异常,并且如果你catch段中获取 response.StatusCode 会得到 404。