Using System;
Using System. Collections. Generic;
Using System. text;
Using Opennetcf. Media. waveaudio;
Using System. IO;
Namespace Record
{
Class Tools
{
Private Static Stream recordstream;
Private Static Recorder = New Recorder ();
Private Static Player player = New Player ();
Public Static Void Recordstart (string recordfile)
{
Recordstream = File. openwrite (recordfile );
Recorder. recordfor (recordstream, 60 * 10 , Soundformats. mono8bit11khz );
// Recorder. recordfor (recordstream 1000 );
}
Public Static Void Recordstop ()
{
While (recorder. recording)
{< br> recorder. stop ();
system. windows. forms. application. doevents ();
}< BR >}
Public static void play (string recordfile)
{< br> stream = file. openread (recordfile);
player. play (Stream);
}
Public static string createrecordfile ()
{< br> return datetime. now. tostring ( " yyyymmddhhmmss " ) + " . wav " ;
}
Public Static String getcurpath ()
{
Return System. Io. Path. getdirectoryname (system. reflection. Assembly. getexecutingassembly (). getname (). codebase );
}
}
}
Using System;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. text;
Using System. Windows. forms;
Using System. IO;
Namespace Record
{
Public Partial Class Form1: Form
{
String recordfile = "" ;
Public Form1 ()
{
Initializecomponent ();
}
Private VoidForm1_load (ObjectSender, eventargs E)
{
}
Private Void Button#click ( Object Sender, eventargs E)
{
Recordfile = Tools. getcurpath () + " \\ " + Tools. createrecordfile ();
Tools. recordstart (recordfile );
}
Private VoidButton2_click (ObjectSender, eventargs E)
{
Tools. recordstop ();
}
Private Void Button3_click ( Object Sender, eventargs E)
{
If (File. exists (recordfile ))
{
Tools. Play (recordfile );
}
Else
{
MessageBox. Show ( " The audio file does not exist! " );
}
}
Private VoidMenuitem1_click (ObjectSender, eventargs E)
{
}
Private VoidMenuitem2_click (ObjectSender, eventargs E)
{
Application. Exit ();
}
}
}
/Files/tt_mc/record.rar