Function
Although vb.net read XML configuration information is convenient, but sometimes the process of development or to use the INI file, in the vb.net read INI is not as convenient as VB, just wrote a function, now posted, perhaps you can use.
' Function name: Sdgetiniinfo
' function: Read INI file settings information
' Parameter description: Inifile-->ini file Inisection--ini the part name set in the file
' Author: SD
' Date: 2005-10-11
' Email:ztqas@126.com
' Remark: Reprint or modify please keep this information
Function Sdgetiniinfo (ByVal iniFile As String, ByVal inisection as String) as String
If not file.exists (iniFile) Then
Return "file" & IniFile & not found, make sure the path and filename are correct! "
Exit Function
End If
Dim Iniread as New StreamReader (iniFile)
Dim inistr as String = Iniread.readtoend
Dim I as Integer
Dim Cline as Integer
Dim nosec as Boolean = False
Dim GetValue as String = ""
Dim Clst
Clst = Inistr.split (Chr (13))
Cline = UBound (CLST)
for i = 0 to cline
If clst (i) indexof ("=") > 0 Then
If clst (i). Split ("=") (0). Trim () = Inisection Then
nosec = True
GetValue = Clst (i). Split ("=") (1). Trim ()
Exit for
End If
End If
Next
If nosec = True Then
Return GetValue
Else
Return "did not find" & inisection & "Settings information! "
End If
End Function
Description: In the referenced face page, you must first refer to the Imports System.IO
EG:
Set.ini File Contents:
[Info]
Name=zhuang
Age=20
Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim name as String
Name = Sdgetiniinfo (Application.startuppath & "\set.ini", "name")
MsgBox (name)
End Sub