I am exporting some generated Serial Code in 3 formats (with C# Asp.Net MVC): .txt, .csv and .xls. The thing is in .txt and .xls the Code is in the right format. But in .csv it loses its leading 0 if it starts with 0 and example:
183531982165
is shown like
1,83532E+11
This is the code snipped I use to fill the file:
public static byte[] CreateFile(SericalCodeModel scObj, myDB db)
{
using (System.IO.FileStream fs = new System.IO.File.Create(filePath))
{
using (System.IO.TextWriter wr = new System.IO.StreamWriter(fs))
{
List<List<string>> fileLines = db.Get<SerialCode>().GetSerialcodeOutDataToFile(scObj); // the db records
foreach (List<string> fileLine in fileLines)
{
wr.WriteLine(string.Join(";", fileLine));
}
}
}
}
This error occurs only when I open the file with Excel, otherwise, with any other editor like notepad it is shown how it is!
Why is that and how can I fix that error?