当前位置: 代码迷 >> ASP.NET >> 求教个路径有关问题!
  详细解决方案

求教个路径有关问题!

热度:6364   发布时间:2013-02-26 00:00:00.0
求教个路径问题!!!!!!!!!!!!!!!!!

为什么我用dstCust.WriteXml(Server.MapPath(path))系统提示path路径有问题
但换成dstCust.WriteXml(Server.MapPath( "bin/cs/cs.xml "))就没有问题

Dim   objConn   As   SqlConnection
                Dim   usern   As   String   =   "cs "
                Dim   path   As   String   =   HttpContext.Current.Server.MapPath( "bin/ "   +   usern   +   "/cs.xml ")
                Dim   strSql   As   String
strSql   =   "SELECT   *   FROM   test "
                objConn   =   New   SqlConnection(ConfigurationManager.AppSettings( "scon "))
                Dim   sdaCust   As   New   SqlDataAdapter(strSql,   objConn)
                Dim   dstCust   As   New   DataSet()
                sdaCust.Fill(dstCust,   "test ")
                dstCust.WriteXml(Server.MapPath(path))

------解决方案--------------------------------------------------------
Server.MapPath是web应用程序 的根路径
------解决方案--------------------------------------------------------
Dim path As String = HttpContext.Current.Server.MapPath( "bin/ " + usern + "/cs.xml ") dstCust.WriteXml(Server.MapPath(path))用了两次MapPath
  相关解决方案