{
MyCRM.DB db = new MyCRM.DB();
if (System.IO.File.Exists(filepath))
{
System.IO.File.Delete(filepath);
}
System.IO.FileStream fsDestFile = System.IO.File.Open(filepath, System.IO.FileMode.OpenOrCreate);
System.IO.StreamWriter srDestFile = null;
DataTable dt = db.ececSelectSql(strsql);
string str = "";
foreach (DataRow dr in dt.Rows)
{
string str1 = "";
for (int i = 0; i < dr.ItemArray.Length; i++)
{
switch (dr[i].ToString())
{
case "":
str1 += " ,";
break;
default:
str1 += dr[i].ToString().Trim() + ",";
break;
}
}
str1 = str1.Remove(str1.Length - 1, 1) + " ";
str += str1;
}
srDestFile = new System.IO.StreamWriter(fsDestFile, System.Text.Encoding.Default); //重要
srDestFile.WriteLine(str);
srDestFile.Flush();
srDestFile.Close();
}