hi,
i read a text file and i want to add multiple strings to the line i'm reading.
let s say for exemple : i read a text file, i want to had "m " and "ing"
the new line will be : i m reading a text file.
i m using stringbuilder.insert.
Insert(Int32, String, Int32) Inserts one or more copies of a specified string into this instance at the specified character position.
i create an objet : with the position, the string i want to had, and the number of time i want to repeat it.
here is part of my code:
StreamReader sr = new StreamReader(line);
StreamWriter sw = new StreamWriter();
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
StringBuilder sb= new StringBuilder(line);
foreach(fields field in listfield)
{
sb.Insert(field.position,field.string, field.numberOftime);
}
sw.WriteLine(builder.ToString());
the problem is that the index changes. For the "ing" will be sb.insert(9,'ing',1) and not (7,"ing",1) and it's normal, but for the user: he only want to add in (7,"ing,1").
Any idea of how can i do it ?
Thx for your help