هل يمكن استعمال iniread لقراءه اسطر متعددة
مثلآ يوجد ملف Settings.txt مكتوب فيه
ini class
مثلآ يوجد ملف Settings.txt مكتوب فيه
إقتباس :Set=test1هل يمكن اضافة الكلام الى بعد Set ال هما test1 test2 test3 فى listbox بدون تكرار الكود مثل هذا
Set=test2
Set=test3
somethingelse=0
somethingelse=2
كود :
Dim test As iniFile = New iniFile(Application.StartupPath + "\Settings.ini")
For Each I In test.IniReadValue("Settings", "Set")
ListBox1.Items.Add(I.ToString())
Next
كود :
Imports System.Text
Public Class iniFile
Public path As String
Private Declare Auto Function WritePrivateProfileString Lib "kernel32" (ByVal section As String, ByVal key As String, ByVal val As String, ByVal filePath As String) As Long
Private Declare Auto Function GetPrivateProfileString Lib "kernel32" (ByVal section As String, ByVal key As String, ByVal def As String, ByVal retVal As StringBuilder, ByVal size As Integer, ByVal filePath As String) As Integer
Public Sub New(ByVal INIPath As String)
MyBase.New()
Me.path = INIPath
End Sub
Public Sub IniWriteValue(ByVal Section As String, ByVal Key As String, ByVal Value As String)
iniFile.WritePrivateProfileString(Section, Key, Value, Me.path)
End Sub
Public Function IniReadValue(ByVal Section As String, ByVal Key As String) As String
Dim temp As StringBuilder = New StringBuilder(255)
Dim i As Integer = iniFile.GetPrivateProfileString(Section, Key, "", temp, 255, Me.path)
Return temp.ToString
End Function
End Class