我在下面的代码中遇到了错误:
路径中有非法字符
请帮我解决这个问题。
response.Clear();
response.Charset = "";
Response.ContentEncoding = System.Text.Encoding.Default;
// set the response mime type for excel
response.ContentType = "application/vnd.ms-excel";
string sFileName = "Testeeeeee.xls";
response.AddHeader("Content-Disposition", "attachment;filename=\"" + sFileName + "\"");
// create a string writer
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// instantiate a datagrid
DataGrid dg = new DataGrid();
dg.DataSource = DS.Tables[0];
dg.DataBind();
dg.RenderControl(htw);
string sPath = @"E:\CR-12\Test.xls";
File.WriteAllText(sw.ToString(), sPath);// I get the error at this line
response.End();