1.0-northcote/cs/Sharpen/frmSharpen.cs
/// <summary>
/// Exports data to a file using a <see cref="System.Windows.Forms.SaveFileDialog"/>.
/// </summary>
/// <exception cref="System.ApplicationException">Exception thrown if an unknown file type is selected.</exception>
Exports data to a file using a .
Exports data to a file using a .
private void ExportFile()
        {
            if (dfsExport.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    this.filePerms = new FileIOPermission(FileIOPermissionAccess.Write, dfsExport.FileName);
                    this.filePerms.Demand();
                    IDataFormatter formatter;
                    if (dfsExport.FilterIndex == 1)
                    {
                        formatter = new CsvDataFormatter();
                    }
                    else if (dfsExport.FilterIndex == 2)
                    {
                        formatter = new JsonDataFormatter();
                    }
                    else if (dfsExport.FilterIndex == 3)
                    {
                        formatter = new XmlDataFormatter();
                    }
                    else
                    {
                        throw new ApplicationException("Unknown file type selected");
                    }
                    formatter.ExportData(this.encounter, new FileStream(dfsExport.FileName, FileMode.OpenOrCreate));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, this.sharpenTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
private void ExportFile ( ) { if ( dfsExport . ShowDialog ( ) == DialogResult . OK ) { try { this . filePerms = new FileIOPermission ( FileIOPermissionAccess . Write , dfsExport . FileName ) ; this . filePerms . Demand ( ) ; IDataFormatter formatter ; if ( dfsExport . FilterIndex == 1 ) { formatter = new CsvDataFormatter ( ) ; } else if ( dfsExport . FilterIndex == 2 ) { formatter = new JsonDataFormatter ( ) ; } else if ( dfsExport . FilterIndex == 3 ) { formatter = new XmlDataFormatter ( ) ; } else { throw new ApplicationException ( " " ) ; } formatter . ExportData ( this . encounter , new FileStream ( dfsExport . FileName , FileMode . OpenOrCreate ) ) ; } catch ( Exception ex ) { MessageBox . Show ( ex . Message , this . sharpenTitle , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ; } } }
Exports data to a file using a .
Exports data to a file using a .
Exception thrown if an unknown file type is selected.
Exception thrown if an unknown file type is selected .