Skip navigation
Currently Being Moderated

Bit by bit copy binary file

Feb 23, 2009 2:45 PM

Hello everyone,

I am trying to copy a binary file using a bit by bit method (I'm going to modify the file's code in future, that's why I want to use such method).

My code is:

var fmsInstallerFile:File = File.applicationDirectory.resolvePath("bin\\sth.exe");
var fmsInstallerStream:FileStream = new FileStream();, FileMode.READ);

var file:File = File.desktopDirectory.resolvePath("coppied.exe");
var stream:FileStream = new FileStream();, FileMode.WRITE);

var tempByte;
for(var i:int = 0; i < fmsInstallerStream.bytesAvailable-1; i ++)
fmsInstallerStream.position = i;
tempByte = fmsInstallerStream.readByte();

I don't know why, but this method is not working as it should. I cannot execute the coppied file, and its size is nearly half of the original one. What is wrong in my code?

Thank you in advance for any reply.
  • Currently Being Moderated
    Feb 24, 2009 10:30 AM   in reply to MazAwushu
    You probably read fmsInstallerStream.bytesAvailable to a variable.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points