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.

Recommended Answers

All 3 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.