小弟我最近刚刚开始用ASP.NET 做了个生成TXT文件的例子. 现在想把生成的数据改变下格式例子如下
   目前生成的文件样式:
001 FENG NO.1                 30328B    3003-3-28
002 VELOCITY                  017E      2005-10-17
005 VISION                    018E      2005-10-26
007 DISCOVERY                 048E      2005-10-10
005 EXPEDITOR                 021E      2005-10-4
007 ENCORE                    029E      2005-10-11
   希望中的样式:
001;FENG NO.1;30328B;3003-3-28
002; VELOCITY;017E;2005-10-17
005; VISION;018E;2005-10-26
007; DISCOVERY;048E;2005-10-10
005;EXPEDITOR;021E;2005-10-4
007;ENCORE;029E;2005-10-11代码:
                           //之前是链接数据库部分
HttpResponse resp;
resp = Page.Response;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); 
resp.AppendHeader("Content-Disposition", "attachment;filename=test.txt");
StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
int i,j;
for(i=0;i<=ds.Tables[0].Rows.Count-1;i++)
{
for (j=0;j<=ds.Tables[0].Columns.Count-2;j++)
{
resp.Write(Convert.ToString(ds.Tables[0].Rows[i][j]).ToString());
}
if (j==ds.Tables[0].Columns.Count-1)
{
resp.Write((Convert.ToDateTime(ds.Tables[0].Rows[i][j])).ToString("d")+"\r\n");
}
}