怎样通过XML保存和读取程序的设置呢?
怎样通过XML保存和读取程序的设置呢? --------------------编程问答-------------------- 哪位老兄说说!? --------------------编程问答-------------------- 参考下如下:' 读XML
gdsConfig.ReadXml(gstrIniFileName) ' XML文件路径
Try
gstrCompanyName = gdsConfig.Tables("Registration").Rows(0)("CompanyName")
gstrServerIP = gdsConfig.Tables("socket").Rows(0)("ServerIP")
gintPort = gdsConfig.Tables("socket").Rows(0)("port")
If gstrServerIP = "" Or gintPort = 0 Or gstrCompanyName = "" Then
strError = "读取配置文件信息失败。"
End If
Catch ex As Exception
strError = ex.Message
Finally
End Try
' 更新XML
Dim strServerIP As String
Dim strPort As String
Try
gdsConfig.Tables("Socket").Rows(0)("ServerIP") = strServerIP
gdsConfig.Tables("Socket").Rows(0)("Port") = strPort
gdsConfig.WriteXml(gstrIniFileName, XmlWriteMode.IgnoreSchema)
gstrServerIP = strServerIP
gintPort = CInt(strPort)
Catch ex As Exception
strError = ex.Message
End Try
补充:.NET技术 , VB.NET