Ejemplo n.º 1
0
        private void exportAllAudiosButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            // save file on .WAV format
            saveFileDialog1.Filter           = "Pasta Compactada (.zip)|*.zip";
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.FileName         = resultComboBox.Text + "_audios";

            // only saves if there is one selected result to save
            if (audioPathDataGridView.Rows.Count != 0)
            {
                if (saveFileDialog1.ShowDialog() == DialogResult.OK) // abre caixa para salvar
                {
                    string directory = Path.GetDirectoryName(saveFileDialog1.FileName) + "\\" + Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
                    FileManipulation.CreateFolder(directory);
                    for (int i = 0; i < audioPathDataGridView.Rows.Count; i++)
                    {
                        string audioPath = audioPathDataGridView.Rows[i].Cells[1].Value.ToString();
                        FileManipulation.CopyFile(audioPath, directory + "\\" + Path.GetFileName(audioPath), true);
                    }
                    FileManipulation.CreateZip(directory, saveFileDialog1.FileName);
                    FileManipulation.DeleteFolder(directory);
                }
            }
            else
            {
                MessageBox.Show(LocRM.GetString("selectDataFile", currentCulture));
            }
        }