I want to download an Excel sheet to my specific location not to Download folder.
I tried below code. Then the file is download to the "Download" folder. I need to download this file to a given file path.
string filepath = "D:\";
string strDownloadableFilename = "Test.xlsx"
Using (MemoryStream stream = ExportExcel()){
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", strDownloadableFilename));
stream.WriteTo(Response.OutPutStream); ;
Response.End();
}
The file is download to "Download" folder.
答案 0 :(得分:0)
有两件事 首先,downoad选项无法完成您想要实现的目标,这意味着我们可以根据需要的位置读取文件并在系统内存中进行写入,但是在这种情况下,不会看到任何下载弹出窗口,因此您必须确定是否需要下载弹出窗口,并且没有所需的位置,反之亦然。