title: C# console application save excel file (do not prompt)
body: <p>I want to write a console application where I will pull data into a dataset. I then want to save the file to a local hard drive. I have the code in my webapp which prompts the user to save it, but I would like to save it to local hard drive of the server and send email to user. Here is my code so far:</p>
  
  <pre><code>Response.Clear();
  Response.ContentType = "application/octet-stream";
  Response.AddHeader("Content-Disposition", "attachment; filename=Test.xls;");
  Response.Charset = "";
  
  System.IO.StringWriter sw = new System.IO.StringWriter();
  HtmlTextWriter htw = new HtmlTextWriter(sw);
  dg.RenderControl(htw);
  Response.Write("&lt;style&gt;.fraction { mso-number-format:#\\/#; }&lt;/style&gt;");                   
  Response.Write(sw.ToString());
  
  Response.End();
  </code></pre>
  
  <p>I would appreciate any help. Thanks.</p>