比如在一个网站中,我新建一个目录叫song,这样我用 Server.MapPath("song")可以显示出song文件夹的绝对路径,但是我在song文件夹下面放了一个文件a.mp3,我如何显示a.mp3的绝对路径?用Server.MapPath("a.mp3")好像不行

解决方案 »

  1.   

    string str = Server.MapPath("song/a.mp3");
      

  2.   

    string str = Server.MapPath("~/song/a.mp3");
      

  3.   

    string path = Server.MapPath("~/song/a.mp3");
      

  4.   

    貌似1,2楼的方法都可以,请问楼上各位,this.getServletContext().getRealPath()这个在.net中可不可以用啊,这个是我在jsp中学到的???
    还有,我显示出路径下面最后一句为啥提示错误?(The control must be in the control tree of a page.
    Parameter name: control)
            string a = Server.MapPath("~/SONG/a.mp3");
            UpdatePanel udp=new UpdatePanel();
            ScriptManager.RegisterStartupScript(udp,typeof(UpdatePanel),"d", "alert(a);",true);
      

  5.   

    this.getServletContext().getRealPath()不能在.net使用