title: how to save exception in txt file?
body: <pre><code>public DataTable InsertItemDetails(FeedRetailPL objFeedRetPL)
  {
      DataTable GetListID = new DataTable();
      try
      {
          SqlParameter[] arParams = new SqlParameter[4];
  
          arParams[0] = new SqlParameter("@Date", typeof(DateTime));
          arParams[0].Value = objFeedRetPL.requestdate;
  
      }
      catch (Exception ex)
      {
          string dir = @"C:\Error.txt";  // folder location
          if (!Directory.Exists(dir))
          {
              Directory.CreateDirectory(dir);
              File.AppendAllText(Server.MapPath("~/Error.txt"), "Message :" + ex.Message + "&lt;br/&gt;" + Environment.NewLine + "StackTrace :" + ex.StackTrace +
         "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
              string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
              File.AppendAllText(Server.MapPath("~/Error.txt"), New);
          }
      }
  }
  </code></pre>
  
  <p>Here, I want to save an Exception in "C:\" ..I am trying In DAL... How to save the Exception In
  C drive Error.txt</p>