StreamWriter also has a large number of overloaded constructors. Whenever you write to a file you must include the encoding format; otherwise , all sorts of bad things can happen. Shown below is a typical StreamWriter sequence:
if(!File.Exists("SpareShort.dta") { MessageBox.Show("Cannot find file 'SpareShort.dta'."); return; } // Begin file opening and writing with 'StreamWriter'. // This next line provides a 'string' to write to file 'SpareShort.dta'. string strWNWBlock = "0444 04-44 22222.22 33333.33 444.44". ToString(); // Open existing file 'ShortSpare.dta' and write to it. // 'true' below means 'append to file'. 'false' means overwrite. StreamWriter jj = new StreamWriter("ShortSpare.dta", false, Encoding.ASCII, 47); jj.Write(strWNWBlock); jj.Close();