Example #1
0
File: MainUI.cs Project: Palpid/qif
        private void exportButton_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                QifDocument qif      = (QifDocument)qifDomPropertyGrid.SelectedObject;
                string      fileName = saveFileDialog.FileName;
                using (StreamWriter writer = new StreamWriter(fileName))
                {
                    writer.AutoFlush = true;

                    qif.Save(writer);
                }
                MessageBox.Show(this, "The export is complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public bool Save(TransactionCollection transactions, string filePath)
        {
            bool success = true;

            try
            {
                QifDocument doc = GetQifDocument(transactions);

                using (FileStream stream = File.Open(filePath, FileMode.OpenOrCreate))
                {
                    doc.Save(stream);
                }
            }
            catch (Exception ex)
            {
                Logger.Logs.Instance.Log(ex);
                success = false;
            }
            return(success);
        }