Click here to Skip to main content
15,170,078 members
Articles / Programming Languages / C#
Posted 10 Aug 2007


30 bookmarked

Reader of SWF Header File in Pure C#

Rate me:
Please Sign up or sign in to vote.
3.75/5 (10 votes)
10 Aug 2007CPOL
Reader of SWF header file in pure C# with a single class
Screenshot - SwfHeaderReader.jpg


It's my first article on The Code Project. Please excuse my English.

This article describes how to read the header of the flash file. (This file has the extension .swf )

The Format Header SWF is described in this link.

You can also read a good article on SWF which describes the library SwfDotNet.

I wrote this article for myself and for people who want small source code.
To read this header, I translate PHP code to C#. The original source code in PHP is at this address.

This is the code of a class which can provide information of the Swf Flash:

  • FrameRate
  • FrameCount
  • Width
  • Height
  • Version

Warning, this class doesn't work with the compressed Flash File.

Using the Code

The name of the class is FlashHeaderReader and takes for the constructor a parameter, the filename of the flash file.

It calls these methods:

  • ReadSignature();
  • mVersion=GetNextByte();
  • ReadFileLength();
  • ReadFrameSize();
  • ReadFrameRate();
  • ReadFrameCount();

Later, you can access the properties of the swf file :

FlashHeaderReader swfreader = new FlashHeaderReader(openFileDialog1.FileName);

listBox1.Items.Add("Frames : " + swfreader.FrameCount);
listBox1.Items.Add("Width : " + swfreader.Width );
listBox1.Items.Add("Height : " + swfreader.Height);

Points of Interest

The method ReadFrameSize is complex because the swf format also compresses the header and information has a different size.


  • 10th August, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
France France
No Biography provided

Comments and Discussions

QuestionHow does it handle garbage collection i cant dispose reader object Pin
SeekKnowledge9-Dec-12 20:12
MemberSeekKnowledge9-Dec-12 20:12 
AnswerRe: How does it handle garbage collection i cant dispose reader object Pin
zebulon750187-May-13 10:09
Memberzebulon750187-May-13 10:09 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey26-Feb-12 22:12
professionalManoj Kumar Choubey26-Feb-12 22:12 
NewsCode Snipped to implement Duration Pin
Horst Klein24-Nov-11 1:59
MemberHorst Klein24-Nov-11 1:59 
Questioninfo shown are totally off Pin
Member 842930423-Nov-11 23:53
MemberMember 842930423-Nov-11 23:53 
GeneralMy Vote of 5 Pin
Alan Burkhart11-Jun-11 7:12
MemberAlan Burkhart11-Jun-11 7:12 
GeneralRe: My Vote of 5 Pin
zebulon750187-May-13 10:07
Memberzebulon750187-May-13 10:07 
GeneralMy vote of 1 Pin
gunjan9um13-Jul-09 2:36
Membergunjan9um13-Jul-09 2:36 
GeneralMy vote of 1 Pin
crayzeecoder25-Jun-09 22:45
Membercrayzeecoder25-Jun-09 22:45 
GeneralRead FLV and Real Media file meta data Pin
Vishal Dedaniya22-Dec-08 11:42
MemberVishal Dedaniya22-Dec-08 11:42 
GeneralRe: Read FLV and Real Media file meta data Pin
Member 438714318-Feb-09 4:16
MemberMember 438714318-Feb-09 4:16 
QuestionCan we read Compressed SWF files Pin
Shikhardadhich17-Sep-08 21:31
MemberShikhardadhich17-Sep-08 21:31 
AnswerRe: Can we read Compressed SWF files Pin
zebulon750181-Dec-08 10:09
Memberzebulon750181-Dec-08 10:09 
GeneralImproving read efficiency Pin
dssdss11-Oct-07 19:18
Memberdssdss11-Oct-07 19:18 
GeneralRe: Improving read efficiency Pin
zebulon7501812-Oct-07 3:34
Memberzebulon7501812-Oct-07 3:34 
QuestionVector info? Pin
Vuvirt10-Oct-07 10:34
MemberVuvirt10-Oct-07 10:34 
AnswerRe: Vector info? Pin
zebulon7501812-Oct-07 3:39
Memberzebulon7501812-Oct-07 3:39 
GeneralRe: Vector info? Pin
Vuvirt14-Oct-07 23:49
MemberVuvirt14-Oct-07 23:49 
QuestionDoes this work with FLV files?? Pin
dclark12-Aug-07 14:01
Memberdclark12-Aug-07 14:01 
AnswerRe: Does this work with FLV files?? Pin
SteveSM214-Aug-07 23:55
professionalSteveSM214-Aug-07 23:55 
GeneralRe: Does this work with FLV files?? Pin
zebulon7501820-Aug-07 0:30
Memberzebulon7501820-Aug-07 0:30 
AnswerRe: Does this work with FLV files?? I guess No :( Pin
zebulon7501820-Aug-07 0:27
Memberzebulon7501820-Aug-07 0:27 
GeneralRe: Does this work with FLV files?? Pin
zebulon750186-Feb-08 4:35
Memberzebulon750186-Feb-08 4:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.