INI Reader / Writer Class for C#, VB.NET, and VBScript - CodeProject
One of the first links from google.
the title say it all ?
Like in PerX ? any one can help please because i want to make a advance injector
Heres my example
INI Reader / Writer Class for C#, VB.NET, and VBScript - CodeProject
One of the first links from google.
Either that or use XML... and not inis
Light travels faster than sound. That's why most people seem bright until you hear them speak.
Or you could use Jason's library for reading and writing .INI files:
https://www.mpgh.net/forum/27-coders-...e-parsing.html
The highlight tag fucked up the code. Hopefully you can figure out the right code for yourself.
can you help me ?
my problem is i cant Load my ListBox i use this to save my settings -> https://www.mpgh.net/forum/33-visual-...-settings.html
Heres my Code
Red Color Contains = Error
Code:Private Sub SaveInformation() 'Write the form "title" to section "General" inifile.WriteValue("General", "Process ", txtText.Text) inifile.WriteValue("General", "Quit ", chkBox1.Checked) inifile.WriteValue("General", "ListBox", ListBox1.Items.Count) End Sub Private Sub LoadInformation() 'Read the form "title" of the section "General" txtText.Text = inifile.ReadValue("General", "Process ", "") chkBox1.Checked = inifile.ReadValue("General", "Quit ", "") ListBox1.Items.Count = inifile.ReadValue("General", "Quit ", "") End Sub
---------- Post added at 09:42 AM ---------- Previous post was at 09:38 AM ----------
thanks but the code is for C# i want code from VB Thanks for the help
You do realize that ListBox1.Items.Count is ReadOnly right? which means you cant edit it.
Also, the reason .NET devs did not include a Library for INI files is because they want YOU to use XML. If so, why no using it? meh..
Light travels faster than sound. That's why most people seem bright until you hear them speak.
Sigh. Replace the red line of your code to this:
Code:ListBox1.Items.Add(inifile.ReadValue("General", "Quit ", ""))
Something like:
I might have done it a bit wrong or so.Code:For Each Opti As String In File.ReadAllLines("Path of file") 'Reads all the lines from the File Dim TempStr As String = Opti 'Makes a new String Temp Valu. (Maybe not needed tho :P) TempStr.Remove(0, TempStr.IndexOf("=")) 'Removes text until it finds: = (You might have to add: TempStr.IndexOf("=") + 1 ListBox1.Items.Add(TempStr) 'Adds the Value to the listbox Next
But I suppose you can see the point here.
This line doesn't affects TempStr. You gotta assign TempStr the value which is returned after the Remove function is called. Also, you're getting the index of is euqal to sign '='. The Remove function removes everything excluding the character that resides on that index. So you gotta add the = sign by incrementing the count by 1.Code:TempStr.Remove(0, TempStr.IndexOf("="))
Anyways, I added a couple of checks. Here's another version that can work for you:Code:TempStr = TempStr.Remove(0,TempStr.IndexOf("=") + 1)
Code:Dim INIFile As String = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\INI.ini" For Each Line As String In File.ReadAllLines(INIFile) If Not Line.Trim().StartsWith("[") And Not Line.Trim().EndsWith("]") And Line.Contains("=") Then Dim SettingName As String = Line.Substring(0, Line.IndexOf("=")) Dim SettingValue As String = Line.Substring(Line.IndexOf("=") + 1) ListBox1.Items.Add(SettingValue) End If Next
Last edited by Hassan; 07-20-2012 at 01:56 PM.
Jorndel (07-20-2012)
Yeah, forgot to assign the new value :P
Getting older by each day
Protip: Use XML instead of INI files.
The fish trap exists because of the fish.
Once you've gotten the fish you can forget the trap.
The rabbit snare exists because of the rabbit.
Once you've gotten the rabbit, you can forget the snare.
Words exist because of meaning.
Once you've gotten the meaning, you can forget the words.
Where can I find a man who has forgotten words so I can talk with him?
The fish trap exists because of the fish.
Once you've gotten the fish you can forget the trap.
The rabbit snare exists because of the rabbit.
Once you've gotten the rabbit, you can forget the snare.
Words exist because of meaning.
Once you've gotten the meaning, you can forget the words.
Where can I find a man who has forgotten words so I can talk with him?
The fish trap exists because of the fish.
Once you've gotten the fish you can forget the trap.
The rabbit snare exists because of the rabbit.
Once you've gotten the rabbit, you can forget the snare.
Words exist because of meaning.
Once you've gotten the meaning, you can forget the words.
Where can I find a man who has forgotten words so I can talk with him?