Click here to Skip to main content
13,456,235 members
Click here to Skip to main content
Add your own
alternative version


30 bookmarked
Posted 10 Aug 2007

Reader of SWF Header File in Pure C#

, 10 Aug 2007
Rate this:
Please Sign up or sign in to vote.
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

You may also be interested in...


Comments and Discussions

QuestionHow does it handle garbage collection i cant dispose reader object Pin
inamul9-Dec-12 19:12
memberinamul9-Dec-12 19:12 
AnswerRe: How does it handle garbage collection i cant dispose reader object Pin
zebulon750187-May-13 9:09
memberzebulon750187-May-13 9:09 
GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 21:12
membermanoj kumar choubey26-Feb-12 21:12 
NewsCode Snipped to implement Duration Pin
Horst Klein24-Nov-11 0:59
memberHorst Klein24-Nov-11 0:59 
Questioninfo shown are totally off Pin
Member 842930423-Nov-11 22:53
memberMember 842930423-Nov-11 22:53 
GeneralMy Vote of 5 Pin
Alan Burkhart11-Jun-11 6:12
memberAlan Burkhart11-Jun-11 6:12 
GeneralRe: My Vote of 5 Pin
zebulon750187-May-13 9:07
memberzebulon750187-May-13 9:07 
GeneralMy vote of 1 Pin
gunjan9um13-Jul-09 1:36
membergunjan9um13-Jul-09 1:36 
GeneralMy vote of 1 Pin
crayzeecoder25-Jun-09 21:45
membercrayzeecoder25-Jun-09 21:45 
GeneralRead FLV and Real Media file meta data Pin
Vishal Dedaniya22-Dec-08 10:42
memberVishal Dedaniya22-Dec-08 10:42 
GeneralRe: Read FLV and Real Media file meta data Pin
Member 438714318-Feb-09 3:16
memberMember 438714318-Feb-09 3:16 
QuestionCan we read Compressed SWF files Pin
Shikhardadhich17-Sep-08 20:31
memberShikhardadhich17-Sep-08 20:31 
AnswerRe: Can we read Compressed SWF files Pin
zebulon750181-Dec-08 9:09
memberzebulon750181-Dec-08 9:09 
GeneralImproving read efficiency Pin
dssdss11-Oct-07 18:18
memberdssdss11-Oct-07 18:18 
GeneralRe: Improving read efficiency Pin
zebulon7501812-Oct-07 2:34
memberzebulon7501812-Oct-07 2:34 
QuestionVector info? Pin
X3m10-Oct-07 9:34
memberX3m10-Oct-07 9:34 
AnswerRe: Vector info? Pin
zebulon7501812-Oct-07 2:39
memberzebulon7501812-Oct-07 2:39 
GeneralRe: Vector info? Pin
X3m14-Oct-07 22:49
memberX3m14-Oct-07 22:49 
QuestionDoes this work with FLV files?? Pin
dclark12-Aug-07 13:01
memberdclark12-Aug-07 13:01 
AnswerRe: Does this work with FLV files?? Pin
SMStallings14-Aug-07 22:55
memberSMStallings14-Aug-07 22:55 
GeneralRe: Does this work with FLV files?? Pin
vidalc19-Aug-07 23:30
membervidalc19-Aug-07 23:30 
AnswerRe: Does this work with FLV files?? I guess No :( Pin
vidalc19-Aug-07 23:27
membervidalc19-Aug-07 23:27 
GeneralRe: Does this work with FLV files?? Pin
zebulon750186-Feb-08 3:35
memberzebulon750186-Feb-08 3: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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03-2016 | 2.8.180322.1 | Last Updated 10 Aug 2007
Article Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid