Exemple #1
0
        private void bt_ok_Click(object sender, EventArgs e)
        {
            this.Hide();
            // réécriture du fichier de destinations précedentes
            if (!lines.Contains(tb_destination.Text))
            {
                string[] newlines = new string[lines.Length + 1];
                newlines[0] = tb_destination.Text;
                Array.ConstrainedCopy(lines, 0, newlines, 1, lines.Length);
                File.WriteAllLines(filename, newlines);
            }

            archiver = new Archiver(this.tb_destination.Text, this);
            if (this.cb_explode_attachements.Checked)
            {
                archiver.EnableExtractAttachments();
            }
            if (Config.GetInstance().GetOption("TRUNCATE_PATH_TOO_LONG").Equals("TRUE"))
            {
                archiver.EnableTruncatePathTooLong();
            }
            if (Config.GetInstance().GetOption("ASK_PATH_TOO_LONG").Equals("TRUE"))
            {
                archiver.EnableAskPathTooLong();
            }
            string res = archiver.ArchiveItem(mailitem,
                                              this.tb_destination.Text,
                                              this.TB_RENAME.Text);

            if (res == "Ok")
            {
                var customCat = Localisation.getInstance().getString(
                    culture.TwoLetterISOLanguageName,
                    "ARCHIVED_CATEGORY"
                    );
                if (mailitem.Categories == null || mailitem.Categories.Trim().Equals("")) // no current categories assigned
                {
                    mailitem.Categories = customCat;
                }
                else if (!mailitem.Categories.Contains(customCat)) // insert as first assigned category
                {
                    mailitem.Categories = string.Format("{0}, {1}", customCat, mailitem.Categories);
                }

                mailitem.Save();
            }
            MessageBox.Show(res);
            this.Dispose();
        }