路径:"http://IP地址/文件夹名/文件" 
在网上查了一些方法,但都会报错"URL格式不支持",谁来帮帮忙
十分感谢

解决方案 »

  1.   

    string allfile = "http://IP地址/文件夹名/文件";//存放文件                 
    if (File.Exists(rarinfo))
    {
              File.Delete(rarinfo); //删除
    }
      

  2.   

    这样试过了,File.Exists(rarinfo)找不到文件,永远是false
      

  3.   

    貌似得把web 相对路径转成绝对路径   
      

  4.   

    转为相对路径,然后用server.mappath
      

  5.   

    //URL相对路径转换成服务器绝对路径      
    private string urlconvertorlocal(string imagesurl1)  
    {  
        //获取程序根目录  
        string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());  
        //转换成服务器绝对路径  
        string imagesurl2 = tmpRootDir + imagesurl1.Replace(@"/", @"/");   
        return imagesurl2;  
    }  
      

  6.   

    string aa = "http://IP地址/文件夹名/文件";
    string strFilePath = aa.Replace("http://", "");
    if (File.Exists(strFilePath))
    {
    File.Delete(strFilePath);
    if (!File.Exists(strFilePath))
    {
    Response.Write("ok");
    }
    else
    {
    Response.Write("no");
    } }
      

  7.   

    轻轻的问一句,你的这种需求能实现吗?如果是删除你自己网站下的文件应该只要有权限就没有问题,那样的话使用相对路径比较好,如果你想通过绝对路径删除别人网站中的内容那是不可能的,比如加入有个url http://www.baidu.com/download/1.rar,你通过这个url只能下载而不能删除的。
      

  8.   

    楼上几位说的Server.MapPath()
    需要引入System.Web.HttpContext.Current.Server.MapPath这个命名空间么
    为什么添加了system.web.dll之后 
    命名空间只能引入System.Web.HttpContext 再之后就找不到了