How to create .data file in c# -


i want create .data file in c# in following format: -

#section name  data data data  #section name  data data data . . . 

can me out in regard.

you might trying open file more once inside code, lead such exception. approach using stringbuilder instead of using streamwriter write content, , use system.io.file.writealltext write content of stringbuilder file.
using stringbuilder have higher memory use lower io use using streamwriter. more details, read this.

here how using stringbuilder:

string filepath = "c:/temp.data"; // should hold full path of file stringbuilder sb = new stringbuilder();  // of course, should use 1 code create data,  // example purely based on format description.  sb.appendline("#section name").appendline(); sb.appendline("data"); sb.appendline("data"); sb.appendline("data").appendline();  file.writealltext(filepath, sb.tostring()); 

Comments