Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 25 Oct 2007 07:07:02 -0700,    group: microsoft.public.platformsdk.multimedia        back       


Cannot delete file after wmaencoder encouters error   
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.
date: Thu, 25 Oct 2007 07:07:02 -0700   author:   Ian2808

Re: Cannot delete file after wmaencoder encouters error   
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
date: Thu, 25 Oct 2007 11:53:47 -0400   author:   Alessandro Angeli

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us