Reverse the contents of a file

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...

after it is reversed it will look like this.


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 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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

File IO sounds like a killer with that approach.  
You might as well just use two files (one input one output).  

1. Seek to the end of the input file -1.
2. Read a byte, write a byte
3. Seek to the end of the input file -2

But IMHO, it would be better to do the reversal in memory.  The optimized thing would be to read the entire input file into memory, reverse the data in memory, and write the whole memory block back out.  But that approach has the obvious drawback that you likely do not have 32GB of physical memory.  (That approach might still work, but only with a lot of disk swapping at the OS level).

But with limited resources, you need a way to break the process down into smaller chunks.  So you might try to process the file in 1MB blocks.
1. Seek to the end of the file - 1MB
2. Read 1MB into memory
3. Reverse the 1MB block in memory.
4. Write the 1MB block of memory to destination file.
5. Seek to the end of the file - 2MB.
Of course you have to deal with the fact that the file will not be an even number of 1MB blocks, so you'll have to come of with a way of dealing with that last <1MB block.
vpcncAuthor Commented:
The Logic sounds workable
can you provide Code examples to go along with your Logic plan?

I have access to (VB.Net 2010 Prefered)  or 2013

File Selection Popup to select the file to be reversed
to select the Destination file to save the results to

Code to Seek to the end of the file and read 1MB into memory.
Code to reverse the contents of Memory
Code to Output memory to the destination file
The nature of this question very much makes it look like a homework assignment.

Understand that EE's 'terms of use' do not permit experts to provide solutions to academic questions (i.e. experts are not allowed to do other's homework).

I feel like I've already pushed the limits of what EE allows by providing you an outline of how to complete this assignment.  

As such, I'm going to have to limit further responses to answering specific questions... questions best asked by providing coding samples of what you've got so far where experts here can help with questions like 'why won't line 25 compile', or 'why does the program raise an error at line 10', or 'what function can I call to determine a file size'.
vpcncAuthor Commented:
Ha ha ha ha ha  Home work assignment....  
you make me laugh...  

If this was VB6, I'd be done with it..  
but File IO on is much different than it was in VB6. As I have Zero experience with doing File IO on .net, I was hoping that a person with more experience, that perhaps has done File IO a thousand times..  

would be able to provide an example..  
cut and paste from something that you've done like the back of your hand...

Nope,  Not these Experts...   not on a Paid Service..   Oh my gawd, it might be a kid asking for help...

Do you really think they'd pay for this service to get Homework help?  honestly?

Sure I can waste my time searching the net.. But I paid for this service here..
Why did I pay for this service if I'm going to do all my own internet research?

Refund me my Money!
Ever question I ask, I get he same BS from the "Experts"

Duh.. maybe you should do your own research...

and then they expect their Points...
I helped you by making you do your own research..  I posted links to a site you can go visit...
where are my points....    
I need points so I can show how smart I am...
I'm so smart I answered 100 questions today....  Look at my Points total...

Any idiot can google and post a link relative or Not to the subject...
That doesn't make you an "Expert"

I'm a business executive..  at a small company,  in my Mid 50's,  
I wear many different Hat's,  my time is better spent doing other things..
In the real world,  Points mean absolutely nothing....
I don't care how many points you got here...  what counts is "Show me what you know..
show me what you can do for me...  

When I hire someone,  I give them a hands on Test..
Here's a box of Parts..  30 different pieces or so in the box..

What can you tell me about each item in that box..

In that box are
Some mechanical, some pneumatic, some hydraulic, some electronic and electrical...
Some pieces would get assembled together...

If they have the experience they claim to have, they will know what every item is, what it's used for,  maybe they will even know that it's defective and that's why it in the box..
or they will describe how to connect it.  
or they would even put some of the pieces together...

Now thats a real test of an "Expert"

It the same here...  this is my box test...  I asked a question..  give me an "Expert" answer.

That's why I decided to Pay for this service, and expect to get direct answers.
Not this lame  response -
Uh.. well you sound like a child doing a homework assignment and I can't help you.

Fine,  refund me my Money,  I'll spend it to get a REAL expert to answer my questions..
instead of spending it on Points chasers..

Close this Question, I'll seek my answer elsewhere...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vpcncAuthor Commented:
already stated in my post..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.