Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recovering files with vb6

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
Is there a way to build a file recovery utility using vb6?
I have a Sony HD camera with internal memory and plug in card memory that I foolishly selected the format function when what I really wanted to do was change from internal memory format to plug in card memory. The Sony camera touch screen menu is a bit misleading.

The camera appears just like a FAT32 32gb USB memory stick so you can view files and folders normally.
The format process was very quick so I don't think it actually wrote over the original file and I haven't used it since my mistake.

I would want to copy the "deleted" AVCHD (.MTS) files to my computer, not reinstate the original files in the camera like the old Windows DOS Recover routine used to do.

The commercially available ones I have tried only recover Jpgs, Movs and AVIs as they were written some time ago as you can only enter the file types from a fixed list.

If possible what would be the approach?
 
This isn't something I'd recommend trying from VB. But there are tools - yes, free ones - that can help and will find all types of files. One such is The limitation with the free version is that it will only recover files smaller than 1Gb, which may be a problem for video files. But you could at least try it and see whether it is then worth paying to remove the limitation.
 
Thanks.
As part of this exercise I was interested in learning how this is done (as well as recovering my files)
For example how do I view the previously used parts of a disk?
If I could, would I be able to search for the pattern of the start and end of each lost file?
I verified that the first 20 bytes of all my AVCHD (.MTS) files start with the same characters represented by ÿØÿágExifII* z when a simple input function is used on a good file.
I vaguely remember doing this sort of thing in the old DOS days.

I guess if some of the movie files are fragmented, it would be difficult to reassemble them if the fragmentation reference is lost.
 
>For example how do I view the previously used parts of a disk?

Well, once upon a time some of us used to do it through DOS interrupt 21 (as I recall) ...

We can't do that these days, and not with VB. We have to take a different approach.

Here's an outline of the process using Win32 API calls:

1.Get a handle to the drive (CreateFile)
2.Determine sector size (GetDiskFreeSpace)
3.Allocate a data buffer (VirtualAlloc)
4.Find the start of the sector(s) we want to read (SetFilePointer)
5.Read the entire sector(s) in the buffer (ReadFile)

However the problem will be determine where the files start since formatting erases both copies of the File Allocation Table, the core index used by FAT file systems to track where a file starts and the sequence of clusters used by the file (i.e. the 'fragmentation reference' as per your post)

So that means you'd have to search through the sectors looking for the start of your files and somehow reconstructing them sector (or cluster) by sector.

I had a large, detailed technical book that broke down all of FAT for me, but that is long gone (chucked out by a wife who felt I really didn't need all my ancient manuals), but the following wiki page give a fairly good summary of how FAT is layed out, which should help Good luck
 
Yes I too have a wife who continually asks me if I want this or that piece of 'memorabilia' when the local council have one of their 'clean up your junk' kerbside collections. I have to guard it all carefully!
My favorite is an original Cleveland Xt made in 1985. The only wholly Australian manufactured PC's ever made (except for the chips). It was named after the suburb of Cleveland in Brisbane, not Ohio.
It only has a floppy, 5k ram and an orange 10" screen.

Thanks for the info. I shall investigate further.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top