现在的位置: 首页 > 综合 > 正文

WinCE 中操作配置文件

2012年07月25日 ⁄ 综合 ⁄ 共 875字 ⁄ 字号 评论关闭

获取配置文件所在路径

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

 

抱歉!评论已关闭.