tags:

views:

1346

answers:

3

I'd like to allow users of a web-based CMS to upload Flash files and include them in the content. I'll probably use SWFObject to render the flash , but I need the width and height. Is this possible to determine these via C# when I do the upload?

Thanks.

+4  A: 

There is likely an easier way but,

you can download "FlashTools.zip" from http://blogs.msdn.com/mswanson/archive/2006/10/15/example-c-code-for-reading-flash-swf-files.aspx and compile the project. Then add a reference to the "FlashTools.dll" assembly. You can then get height/width using:

SWFFile swf = new SWFFile(fileLocation);
Response.Write("Height:" + swf.FrameHeight/20 + " Width:" + swf.FrameWidth/20);

I've tested this and it shows the correct information.

savageguy
+1  A: 

Perhaps you should also give the user the option to manually enter the width and height for each SWF (as well as the option to auto-detect from SWF bytecode).

I mention this because SWF files are mostly designed to be embedded in HTML and the Stage Size (Flash lingo for dimension) of the SWF is not always intended to be the embed size for that piece of content - some SWFs are designed to automatically resize their contents to match how they are embedded within HTML, so the actual Stage width and height for these SWFs might be irrelevant.

Darscan
A: 

Bonjour, es que je peux utiliser swftool avec vb.net et ou je peux telecharger swftool.dll merci a l'avance