Hi Friends,
I want to split the string after read from INI file. Below is my code.
I have read the line from INI file that which contain the keyword "ABC" at the starting position. Here i want to read the element of ABC that "i,a,s". I can able to read this but the first value shows along with the keyword "ABC". I don't want this. I need only the values. Could anyone help me.
string line;
string charname = string.Empty;
StreamReader file = new
System.IO.StreamReader(@"H:\Dotnet Practice\INI\INI\bin\Debug\emp.ini");
{
while ((line = file.ReadLine()) != null)
{
if (line.StartsWith("ABC"))
{
//string[] fullName = line.Split('=');
// charname = fullName[1];
string[] splitcharname = line.Split(',');
foreach (string splitchar in splitcharname )
{
MessageBox.Show(splitchar);
// if (splitchar == textBox1.Text)
// {
// MessageBox.Show("not allowed");
// }
//break;
}
}
}
INI file input:
ABC=i,a,s
output should be:
i
a
s
Please help me
Regards,
Gopi A
Loading

Sukesh MarlaRank #461 · 5.4K reputationPosted Aug 10, 2012, 11:37 PM EDT
string[] fullName = line.Split('=');
string[] splitcharname = fullName[1] .Split(',');
foreach (string splitchar in splitcharname )
{
MessageBox.Show(splitchar);
}
Hope it helped.
Mark as answer if it is. :)
Moses Spencer20 reputationPosted Mar 23, 2015, 5:50 AM EDT
IniFile ini = new IniFile(); ini.Load(@"H:\Dotnet Practice\INI\INI\bin\Debug\emp.ini"); foreach (IniSection section in ini.Sections) foreach (IniKey key in section.Keys) if (key.Name.StartsWith("ABC")) foreach (string splitchar in key.Value.Split(',')) MessageBox.Show(splitchar);