CSV output not displaying correct format in c#

Jul 24 2014 8:26 AM
Hi,
I have  some doubt regarding  creating CSV files using c#
 
Doubt
===========
I had created  simple program using Streamwritter (using c#).This is generating multiple csv files , but some field like date field are not displaying correct format in which the database file are showing.
 
Example:  Database field : 10 May 2014 
                 Csv field           :10-May-20 
 
Code:
============= 
 
int iColCount = dtDataTablesList.Columns.Count;
int rowcount = dtDataTablesList.Rows.Count;
int loopcount = 3000;
int totalloopcount = loopcount;
int count = 1;
int remainder = rowcount % loopcount;
int Fcount = rowcount / loopcount;
string date = DateTime.Now.Date.ToString();
string datewithTime = DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString();
if (remainder != 0)
{
Fcount = Fcount + 1;
}
for (int iloopcoiunt = 1; iloopcoiunt <= Fcount; iloopcoiunt++)
{
StreamWriter sw = new StreamWriter(@"E:\Biren\" + "Boxinventory" + "_" + datewithTime + "_" + iloopcoiunt + ".csv", true);
for (int i = 0; i < iColCount - 1; i++)
{
sw.Write(dtDataTablesList.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
for (int i = count; i <= totalloopcount; i++)
{
DataRow dr = dtDataTablesList.Rows[i - 1];
for (int k = 0; k < iColCount - 1; k++)
{
if ((dr[k].ToString() != null || dr[k].ToString().Length > 0))
{
sw.Write("\"" + dr[k].ToString() + "\"");
sw.Write(dr[k].ToString());
sw.Write(",", "");
}
}
sw.Write(sw.NewLine);
count += 1;
}
totalloopcount += loopcount;
if (totalloopcount > rowcount)
totalloopcount = rowcount;
sw.Close();
}
 
 
Thanks,
Biren