How to save file in a folder in windows application
<p>I want to send an attachment in an email, SO for that I want to save the attachment file in a folder first.</p>

<blockquote>
  <p>So what's happening with my current code is, the mail is going with attachment but my file is not getting saved into the <code>ATTACHMENT</code> folder.</p>
</blockquote>

<p>here is the code i tried</p>

<pre><code>for (int i = 0; i &lt; table.Rows.Count; i++)
        {
            if (1 == 1)
            {
                string StrPriBody = "This is a test mail for checking notification.";

                MailMessage mail = new MailMessage();
                mail.Subject = "Daily Holding followup scheduler";
                mail.From = new System.Net.Mail.MailAddress("autosupport@powersoft.in");
                SmtpClient smtp = new SmtpClient();
                smtp.Timeout = 1000000;
                smtp.Port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Port"]);
                smtp.UseDefaultCredentials = true;
                smtp.Host = System.Configuration.ConfigurationManager.AppSettings["MailHost"];
                smtp.Credentials = new NetworkCredential(mail.From.ToString(), "PS123456");
                smtp.EnableSsl = true;
                mail.To.Add(new MailAddress("abc@test.com"));
                mail.IsBodyHtml = true;
                mail.Body = StrPriBody;

                DataSet ds = new DataSet();
                ds.Tables.Add(table);
                ds.Tables[0].TableName = "Post sale follow up entries auto mailer";


                SaveFileDialog save = new SaveFileDialog();
                save.InitialDirectory = "\\Attachment";
                save.RestoreDirectory = true;

                ExcelLibrary.DataSetHelper.CreateWorkbook("Employee_Details.xls", ds);

                mail.Attachments.Add(new Attachment("Employee_Details.xls"));

                smtp.Send(mail);

                foreach (Attachment attachments in mail.Attachments)
                {
                    attachments.Dispose();
                }
</code></pre>