Hi, I am using wma encoder 9 sdk to encode files. My problem is that some files are corrupt and need to be deleted. I am trying to do this when encountering an exception as the following code illustrates. Catch ex As Exception Debug.WriteLine(ex.Message) If ex.Message = "No matching media type is found in the source SG_1." Then System.IO.File.Delete(strInputDir & wavPlaceHolder) End If End Try My problem is that the file is only deleted once the program is stopped - Not very good as the program is running as a service and is hardly ever stopped. Any help will be appreciated on how to completely release the encoder before deleting the file.
From: "Ian2808" > I am using wma encoder 9 sdk to encode files. Do you mean the WindowsMediaEncoder9? There is no WMAEncoder9. > My problem is that the file is only deleted once the > program is stopped - Not very good as the program is > running as a service and is hardly ever stopped. My guess is that the file does not get deleted when the program is stopped but when it is unlocked, which happens when the encoder is released which happens when the encoder is garbage collected which happens when the process terminates which happens when you stop the service. If you wait long enough, sooner or later the encoder object is going to be garbage collected. You can force the underlying COM object to be realeased before the RCW is garbage collected using System.Runtime.InteropServices.Marshal.FinalReleaseComObject(). -- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm