在类文件中得到当前根目录找到图片....

解决方案 »

  1.   

    string dir = Server.MapPath("~/");
      

  2.   

    Server.MapPath()可以获取指定相对路径的物理路径
      

  3.   

    http://hi.baidu.com/qzdcj/blog/item/20f342dab5e49470d0164e0d.html
      

  4.   

    类里面需要使用
        System.Web.HttpContext.Current.Server.MapPath("~")
      

  5.   

    用Server.MapPath()获取就可以了~~
      

  6.   

    Server.MapPath(Request.ServerVariables["PATH_INFO"])
    Server.MapPath("/")
    Server.MapPath("")
    Server.MapPath(".")
    Server.MapPath("../")
    Server.MapPath("..") 
           Page.Request.ApplicationPath以上的代码在http://localhost/EnglishClub/manage/WebForm1.aspx页面
    运行结果:
    C:\Inetpub\wwwroot\EnglishClub\manage\WebForm1.aspx
    C:\Inetpub\wwwroot\
    C:\Inetpub\wwwroot\EnglishClub\manage
    C:\Inetpub\wwwroot\EnglishClub\manage
    C:\Inetpub\wwwroot\EnglishClub\
    C:\Inetpub\wwwroot\EnglishClub
      

  7.   

    static string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source = test.mdb";
    test.mdb放在根目录
    怎么得到....
      

  8.   

    本帖最后由 net_lover 于 2011-08-15 12:01:13 编辑