I have a form with an Flash SWF embedded using AxShockwaveFlash. I no longer have the original SWF file and I'd like to extract it from the AxShockwaveFlash object.
I've tried pulling the OCXState out and saving it to disk (via the Immediate Window) like this:
((System.IO.MemoryStream)axShockwaveFlash1.OcxState.ms)
.WriteTo(System.IO.File.OpenWrite(@"C:\Users\Michael\Desktop\Test.swf"))
But the file doesn't appear to be a valid SWF.
How can I extract the embedded Flash file and save to a SWF file?
axShockwaveFlash1.OcxState
represents the persisted state of the Active X control stored as AxHost.State
which when serialized has it's own header meta data. See AxHost.State
Saving this out to a file does create a valid SWF
file but includes the additional meta data for the AxHost.State
. By examining the SWF Header Structure, you can see where the Flash begins and using a safe editor (Notepad++) you can remove everything before that point.