Reta Adam
Reta Adam

Reputation: 5

Save Wav file after recording it automatically

I don't want the user to decide which location of the wav file should be saved , and automatically save it in D:\

private void btnAdd_Click(object sender, EventArgs e)
    {
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.InitialDirectory = @"D:\CIS";
        saveFileDialog.FileName = textBox1.Text;
        Stream fileStream = saveFileDialog.OpenFile();
        this.encoder.Save(fileStream);
    }

Upvotes: 0

Views: 854

Answers (2)

Casey Price
Casey Price

Reputation: 778

If you meant you don't want to prompt the user on where to save the file, and rather just save the file directly, just do

using (Stream fileStream = File.Open(Path.Combine(@"D:\CIS",textBox1.Text) , FileMode.Open))
{
   this.encoder.Save(fileStream), FileMode.Open);
}

Upvotes: 1

Yacoub Massad
Yacoub Massad

Reputation: 27861

Simply open a new file with the filename that you want and write the data to it like this:

string filename = "d:\\file1.wav";

using (Stream fileStream = File.OpenWrite(filename))
{
    this.encoder.Save(fileStream);   
}

Upvotes: 0

Related Questions