Release a wav file from being used by a process

224 views Asked by At

I'm using the MediaPlayer class to open a file and play it like that:

MediaPlayer mplayer = new MediaPlayer();     
mplayer.Open(new Uri("Sounds\\mySendFile.wav", UriKind.Relative));
mplayer.Play();

//Delay some time to finish playing        
await Task.Delay((int)(1000*(bits.Length*BitTime+4*StartDelimiterTime+4*EndDelimiterTime)));

The aboved file is generated before the playing by a concatenation of several little wav files by clicking on a button. Then, if I click again for concatenation I get an exception which points on the generated file as it being used by another process. How can I release it without deleting the file?(I have deleted the file but still it says it is used by another process).

0

There are 0 answers