private void button1_Click(object sender, EventArgs e)
        {
            aTimer = new System.Timers.Timer(3000);
            aTimer.Elapsed += new ElapsedEventHandler(button2_Click);
            aTimer.Enabled = true;
            
            for (int i = 0; i < 16; i++)
            {
                mciSendString("open new Type waveaudio Alias record_sound", "", 0, 0);
                mciSendString("record record_sound", "", 0, 0);
                
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {

            mciSendString("save record_sound c:\\Users\\jamie\\desktop\\jamie.wav", "", 0, 0);
            mciSendString("close record_sound", "", 0, 0);
            MessageBox.Show("!!");
            aTimer.Stop();
        }

I'm try to record a voice using the MCIsendstring and then set timer to save the voice after 3 seconds, but there seems to be an error. The Messagebox.Show works where i can see !! being pop up but i was not able to save the file. The code works if I press the button manually.

Please help.

It could be a threading issue or somthing similar. What happens when you step through it and have you tried using try and catch around the affected code?

Well everything works fine unless the fact that I can't save the wave file.

solved with by using thread instead. Thanks for the help.

This question has already been answered. Start a new discussion instead.