在configuration节点里配置键值,如实例:
<appSettings > <add key ="WebURL" value ="http://localhost:8080/"/> <add key="CorpId" value="28"/> <add key="CorpGuid" value="658FCF24-B3BD-4034-9599-2EFED1056AD8"/> </appSettings>在窗体中读取配置的值
先在项目中引入DLL,添加引用,在.NET中找到System.Configuration确定后,引入到项目;然后在窗体中加入命名空间:
Imports System.Configuration
获取节点中键值:
Dim WebURL As String = ConfigurationManager.AppSettings("WebURL").ToString() Dim CorpGuid2 As String = ConfigurationManager.AppSettings("CorpGuid").ToString() Dim CorpId2 As String = ConfigurationManager.AppSettings("CorpId").ToString()