I would like to know how i should write text to a ini file. The reading of the file is already done. Now i just have to know how to write to the file.
It should look like this when its in the INI file:
[H83052_md7]
Description=H83048 processor mode 7
BootFile=kernel_52.md7
Extension=a20
If you would like to see how i read from the file ask me for the source code please because i could not figure out how i should do this.
I write it like this:
namespace Flashloader
{
class Controllerlist : List<Controller>
{
public Controllerlist FromIniFile()
{
StringList input = new StringList().FromFile("Controllers.ini");
Controller controller = null;
foreach (var item in input)
{
String line = item.Trim();
if (line.StartsWith("[") && line.EndsWith("]"))
{
String name = line.Substring(1, line.Length - 2);
controller = new Controller(name);
Add(controller);
}
else if (controller != null)
{
int index = line.IndexOf('=');
if (index < 0)
continue;
String key = line.Substring(0, index).Trim();
String value = line.Substring(index + 1).Trim();
if (Utils.EqualsIgnoreCase(key, "Description"))
controller.Description = value;
else if (Utils.EqualsIgnoreCase(key, "Bootfile"))
controller.Bootfile = value;
else if (Utils.EqualsIgnoreCase(key, "Extension"))
controller.Extension = value;
}
}
return this;
}
public Controller FindByName(String name)
{
foreach (var item in this)
if (Utils.EqualsIgnoreCase(item.Name, name))
return item;
return null;
}
}
}