Reverse the contents of a file
Posted on 2014-01-09
I have some file types that I need to Reverse the content.
So that the Last byte is the First byte, and the first byte is now the last byte.
Sort of like if you used a FILO buffer as you read and then resave the file byte by byte.
example if the file has this text in it...
ETARDEEF LAUNAM11 EDIRREVO ETARDEEF LAUNAM01 EDIRREVO ETARDEEF LAUNAM9 EDIRREVO ETARDDEF LAUNAM8 EDIRREVO
after it is reversed it will look like this.
OVERRIDE 8MANUAL FEDDRATE OVERRIDE 9MANUAL FEEDRATE OVERRIDE 10MANUAL FEEDRATE OVERRIDE 11MANUAL FEEDRATE
The files can be up to 32GB in size and contain binary data.
( I don't need to reverse the actual Binary bits)
If I read the first Byte of the file and it is 00010001 then I still want to write 00010001 but instead of it being the first byte, it will now be the last byte.
I could code a program to do something like this: with 3 files...
Source file - file to be reversed
Temp File - temporary use
Destination File - results of reversal
1.) Get next Byte from Source
2.) Write Byte to Temp
3.) Get Entire content of the Destination
4.) Copy to end of Temp
5.) Dispose of Destination
6.) Copy Temp to Destination
7.) Dispose of temp
Repeat till all Bytes of the Source have been read.
When done the destination file will now be the reverse of the source file
But doing it byte by byte like this will take a long time...
I wonder if there is an Easier or Quicker way.
I have access to
VB.net VB2010 express or VB2013 express
I would need to be able to Select the Source File
Choose a destination File
then reverse the file.
Sample code and Logic would be very helpful.