1
我想將網格視圖轉換爲excel並將excel表格下載到我的計算機在我的c#應用程序中的特定文件夾。如何避免將文件下載到下載文件夾,並只下載到其他特定文件夾#
問題是:該文件正在下載兩個地方。目標文件夾和下載文件夾。
這個代碼是:
private void ExportToExcel(GridView GrdView, string fname)
{
Response.Clear();
Response.AddHeader("content-disposition", "inline;filename=" + fname + ".xls");
Response.Charset = "";
Response.ContentType = "application/OCTET-STREAM";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
string renderedGridView = stringWrite.ToString();
File.WriteAllText(@"C:\\Users\abc\\Desktop\" + fname + ".xls", renderedGridView);
Response.Write(stringWrite.ToString());
Response.End();
}
如何避免文件得到下載到下載文件夾? 請幫忙! 謝謝
參見:http://stackoverflow.com/questions/6773866/download-file-and-automatically-save-it-to-folder –