获取配置文件所在路径

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

Public Function getServers() As String
        Dim xmldoc As XmlDocument = New XmlDocument

        Dim path As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

        xmldoc.Load(path + "\springlandApp.config")


        Dim node As XmlNode = xmldoc.SelectSingleNode("configuration/servers")

        Return node.InnerText
    End Function

 

Public Sub setServers(ByVal serverpath As String)
        Dim xmldoc As XmlDocument = New XmlDocument

        Dim path As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\springlandApp.config"

        xmldoc.Load(path)

        Dim node As XmlNode = xmldoc.SelectSingleNode("configuration/servers")

        node.InnerText = serverpath

        xmldoc.Save(path)
    End Sub

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
猜你喜欢
  • 2021-10-25
  • 2021-06-17
  • 2021-09-03
  • 2022-01-23
  • 2021-06-05
  • 2021-12-20
  • 2021-12-31
相关资源
相似解决方案