在page是可以用Server.MapPath("test.xml")得到指定文件的路徑,但是在module中用這個是不允許的,不知道有沒其它方法得到指定文件的路徑,謝謝!!

解决方案 »

  1.   

    在module加个属性app_path,在global.asax后台代码的Application_Start里写
    app_path = HttpContext.Current.Request.ApplicationPath.Replace("/", "\")
    则test.xml的路径可以在module里用ApplicationMapPath + "\test.xml"取得
      

  2.   

    HttpContext.Current.Request.ApplicationPath.Replace("/", "\") + "\xml\serverbase.xml"
    得到的路徑是:
    \webconfig\xml\serverbase.xml而Server.MapPath("xml/serverbase.xml")得到的路徑是
    D:\程序\webconfig\xml\serverbase.xml第一個用File.Exists(file_string)判斷說文件不存在。還有其它方法嗎?
      

  3.   

    换一下ApplicationPath,得到你想要的,关于路径的属性可多了,path,physicalpath....看看哪个转换得到得结果是你需要的
      

  4.   

    HttpContext.Current.Request.MapPath("xml/serverbase.xml")
      

  5.   

    //*****你只需继承Page类就可以了哈