0
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xlsx", sheetName.Replace(" ", "_")));

using (var memoryStream = new MemoryStream())
{
    wb.SaveAs(memoryStream);
    memoryStream.WriteTo(HttpContext.Current.Response.OutputStream);
    memoryStream.Close();
}

HttpContext.Current.Response.End();

I want SaveAs Dialog box to show a default specified path e.g. c:\users\joe\ or save the file in specified directory ? How can I do that ?

HpTerm
  • 8,151
  • 12
  • 51
  • 67

1 Answers1

0

You can try to set the DefaultFilePath for your Application object.

wb.Application.DefaultFilePath = @"c:\users\joe";

Source: How to: Get and Set the Default File Path for Workbooks

verm-luh
  • 166
  • 10