Example #1
0
        /// <summary>
        /// Handles the Click event of the neuToolStripButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void neuToolStripButton_Click(object sender, EventArgs e)
        {
            string filename = "";

            // configuring the openFileDialog
            openFileDialog_sound.FileName   = soundDirectory + "\\*.wav";
            openFileDialog_sound.Filter     = "WAV Files (*.wav)|*.wav";
            openFileDialog_sound.DefaultExt = "*.wav";
            // showing the openFileDialog
            if (openFileDialog_sound.ShowDialog() == DialogResult.OK)
            {
                // Get the selected file's path from the dialog and
                // create the file-destination-path.
                filename = openFileDialog_sound.FileName;
                string baseName        = Path.GetFileName(filename);
                string fileDestination = soundDirectory + "\\" + baseName;
                // Check if there is already a file with the name.
                // Otherwise show an error-message.
                if (File.Exists(fileDestination))
                {
                    MessageBox.Show("There is already a file with this name!");
                }
                else
                {
                    if (!Directory.Exists(soundDirectory))
                    {
                        Directory.CreateDirectory(soundDirectory);
                    }
                    File.Copy(filename, fileDestination);
                    manager.AddSoundFile(0, baseName);
                    manager.Save(configFileName);
                    manager.WriteToListView(listView_sounds);
                }
            }
        }