DateTime datatimes;
datatimes=DateTime.Now;
string filepath=System.Configuration.ConfigurationSettings.AppSettings["ConnenctionStringBaseData"]+SCode+datatimes.ToString("yyyy-MM-dd").Substring(0,4)+datatimes.ToString("yyyy-MM-dd").Substring(5,2)+datatimes.ToString("yyyy-MM-dd").Substring(8,2)+".txt";
StreamWriter sw=new StreamWriter(filepath,false,System.Text.Encoding.Default);
sw.BaseStream.Seek(0, SeekOrigin.End);//设置写数据流的起始位置为文件流的末尾
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
sw.Write("\"{0}\" \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\" \"{7}\" \"{8}\" \r\n",
ds.Tables[0].Rows[i][0].ToString(),
ds.Tables[0].Rows[i][1].ToString(),
ds.Tables[0].Rows[i][2].ToString(),
ds.Tables[0].Rows[i][3].ToString(),
ds.Tables[0].Rows[i][4].ToString(),
ds.Tables[0].Rows[i][5].ToString(),
ds.Tables[0].Rows[i][6].ToString(),
ds.Tables[0].Rows[i][7].ToString(),
ds.Tables[0].Rows[i][8].ToString()
);
}
sw.Flush();
sw.Close();