コード例 #1
0
        //save directly to file without prompting
        private void saveFile(string path)
        {
            //create serialization object
            SerializeObject writeMe = new SerializeObject(path, CurrentShow);

            //write data and get result code
            string result = writeMe.writeFile(true);

            //handle according to result
            if (result == "success")
            {
                Changed = false;
            }

            else
            {
                MessageBox.Show("Unable to save file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        //display save prompt before saving
        private void saveFile()
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (saveFileDialog.FileName != null)
                {
                    //create serialization object
                    SerializeObject writeMe = new SerializeObject(saveFileDialog.FileName, this.CurrentShow);

                    //write data and get result code
                    string result = writeMe.writeFile();

                    //handle according to result
                    if (result == "success")
                    {
                        Changed = false;

                        //set global path
                        this.Path = saveFileDialog.FileName;

                        //enable save button
                        saveToolStripMenuItem.Enabled = true;
                    }//end if

                    else if (result == "error")
                    {
                        MessageBox.Show("Unable to open file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }//end else if
                }//end inner if
            }//end main if
        }