I am writing some strings in an Excel file. Sometimes the call to the
StreamWriter.WriteLine()
function unexpectedly creates a "Â" character.
Any idea why?
Update
the code:
StreamWriter writer = new StreamWriter(File.Create(outFile));
string headerline = "";
foreach (DataColumn colum in reportContents.Columns)
{
headerline = headerline + '"' + row[colum].ToString() + '"' + ',';
}
writer.WriteLine(headerline);
the output: Personal Protection |Post-Retirement Savings|Pre-Retirement Pension|Tax & Estate Planning
Expected output: Personal Protection |Post-Retirement Savings|Pre-Retirement Pension|Tax & Estate Planning
I get the solution: just i need to specify the default the encoding in StreamWriter like as follows and it works.
StreamWriter writer = new StreamWriter(File.Create(outFile), Encoding.Default);
shuvra