Thursday, August 7, 2008

Read SWF File As Byte Array

By using the following function we can Read the SWF File as Byte Array

byte[] data= File.ReadAllBytes("Path of the file")
//Save SWF File in Specified Path
string path = "D:\\SWFFiles\\test.swf";
string dirPath = path.Remove(path.LastIndexOf("\\"), (path.Length - path.LastIndexOf("\\")));
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
using (BinaryWriter binWriter = new BinaryWriter(File.Open(path, FileMode.OpenOrCreate)))
{
binWriter.Write(data);
}

2 comments:

Anonymous said...

Thanks Shaalini.It was really very useful

Soni said...

HI Shaalini,
May I know how to read a specified bytes from swf file and write into a new swf file.

Thanks in adavance