News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CopyFile and restore

Started by czDrillard, January 22, 2006, 07:28:37 PM

Previous topic - Next topic

czDrillard

Hello everybody,

I want to create backup copies of files then delete the originals.  For example I copy file C:\MyFolder\my.txt to D:\Temp\my.txt no problem.  I want to save the original location so I know where to restore the files later.  I tried tricking MASM by using destination D:\Temp and appending C:\MyFolder\My.txt  for the file name but of course didn't work.   My question is how do I restore the files to their original locations?  Does anybody have any suggestions of how I can copy the files but still save their original locations?  Any ideas or suggestions much appreciated.


best regards,

czDrillard

zooba

Remove the drive label and replace the backslashes with underscores. If the original filename contains underscores you may need to store extra data with it. If you're targeting NTFS then you can store the original location in a stream attached to the file (use CreateFile with "D:\Temp\my.txt$ORIG_PATH") :U

czDrillard

Hi zooba,

Thanks for the suggestion.  I removed the drive letter and use  SHFileOperation to copy the file.  Then do the reverse to restore.  Seems a bit awkward, but it works :)

best regards,

czDrillard

P1

Cheap and dirty.

Use an archive at the root of the drive.  Then use the "move" operation preserving filepath option.  Then when you restore, you have full path and attributes restored.

Regards,  P1  :8)

czDrillard

Hello P1 and thankyou for your reply.

What exactly does this mean:
QuoteUse an archive at the root of the drive.

best regards,

czDrillard

P1

If you keep the zip file relative to the root of the drive ( just the drive letter, no paths ), then when you "move" your file with a path, it will restore right to the same place.  Otherwise, I can remember a full path option for the zip file as well.   This will enable you to keep the file anywhere.
C:\Drive_Backup.ZIP

Regards,  P1  :8)