Beispiel #1
0
        private void mnuExport_Click(object sender, EventArgs e)
        {
            string filename = loadedUserFile;

            if (!string.Equals(Path.GetExtension(filename), ".asm", StringComparison.OrdinalIgnoreCase))
            {
                filename = Path.ChangeExtension(filename, ".asm");
            }

            FileExporter.FileName = filename;
            if (FileExporter.ShowDialog() == DialogResult.OK)
            {
                string error = null;
                try {
                    File.WriteAllText(FileExporter.FileName, editor.Text);
                } catch (IOException) {
                    error = "An IO error occurred";
                } catch (NotSupportedException) {
                    error = "Invalid path or unsupported operation";
                } catch (UnauthorizedAccessException) {
                    error = "Unauthorized access";
                }

                if (error != null)
                {
                    MessageBox.Show("Failed to export file:" + error, "Export Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }