title: not able to export excel from gridview
body: <p>this is my code:</p>
  
  <pre><code>          protected void btnExcel_Click(object sender, ImageClickEventArgs e)
      {
          try
          {
              DataTable dtbl = (DataTable)ViewState["dtbl"];
              string path = "E:\\shubby" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + ".xls";
              FileInfo fi = new FileInfo(path);
              StringWriter sw = new StringWriter();
              HtmlTextWriter htmltw = new HtmlTextWriter(sw);
              DataGrid grdCrew = new DataGrid();
              grdCrew.DataSource = dtbl;
              grdCrew.DataBind();
  
              grdCrew.RenderControl(htmltw);
              string directory = path.Substring(0, path.LastIndexOf("\\"));// GetDirectory(Path);
              if (!Directory.Exists(directory))
              {
                  Directory.CreateDirectory(directory);
              }
  
              System.IO.StreamWriter vw = new System.IO.StreamWriter(path, true);
              sw.ToString().Normalize();
              vw.Write(sw.ToString());
              vw.Flush();
              vw.Close();
              WriteAttachment(fi.Name, "application/vnd.ms-excel", sw.ToString());
          }
          catch (Exception ex)
          {
              throw new Exception(ex.Message);
          }
      }
  
      public static void WriteAttachment(string FileName, string FileType, string content)
      {
          HttpResponse Response = System.Web.HttpContext.Current.Response;
          Response.ClearHeaders();
          Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
          Response.ContentType = FileType;
          Response.Write(content);
          Response.End();
      }
  </code></pre>
  
  <p>I have seperate file for business logic and stored procedures, everything is working fine, its just the excel export that i am facing trouble with, </p>
  
  <p>the error that i am getting is the exception that says "A required privilege is not held by the client"...</p>
  
  <p>please help</p>