c# - Streamwriter adding characters to first line -
i doing rather simple in c#, writing list of strings text file. write sub is:
public static bool texttofile(string filename, list<string> instring) { if (!directory.exists(path.getdirectoryname(filename))) directory.createdirectory(path.getdirectoryname(filename)); try { if (file.exists(filename)) file.delete(filename); const int buffersize = 65536; // 64 kilobytes using (streamwriter sw = new streamwriter(filename, true, encoding.utf8, buffersize)) { if (instring.count > 0) { foreach (string str in instring) { sw.writeline(str); } } else sw.writeline(""); } return true; } catch { return false; } }
i getting stuff @ beginning of first line though. not show in regular text editor, when opened in ultraedit, , went hex mode, saw this:
my programs read text file see characters, , confuse it. list of strings super clean. writing 100 mb text files, setting buffer 64k, tried leaving default same results. on win7 64 bit, using vs 2013.
Comments
Post a Comment