public static void ExportToSvc(List<Student> dataList, string strFileName)
{
string strPath = strFileName;
if (File.Exists(strPath))
{
File.Delete(strPath);
}
StringBuilder strValue = new StringBuilder();
try
{
StreamWriter sw = new StreamWriter(new FileStream(strPath, FileMode.CreateNew), Encoding.GetEncoding("GB2312"));
foreach (Student data in dataList)
{
strValue.Remove(0, strValue.Length);
strValue.Append(data.GradeID.ToString());
strValue.Append(",");
strValue.Append(data.ClassID.ToString());
strValue.Append(",");
strValue.Append(data.StudentID.ToString());
strValue.Append(",");
strValue.Append(data.Datetime.ToString());
strValue.Append(",");
strValue.Append(data.Data.ToString());
strValue.Append(",");
strValue.Remove(strValue.Length - 1, 1);
sw.WriteLine(strValue);
}
sw.Close();
}
catch (Exception ex)
{
throw ex;
}
System.Diagnostics.Process.Start(strPath);
}