Copying files from a disk

Sorry Zodik, but my customer is still running win 3.1 so I think your nice and quick solution won't do the job here.
My mistake for not specifying the OS. Sorry,

I need to copy  files from several floppy disks. Files need to be
copied to the hard disk in the exact same directory structure as on
the disks. Kind like an installation program. Is there any easy way to
do this, API call or one line of code?
Kris De Decker
Who is Participating?
zodikConnect With a Mentor Commented:
on win95/nt4 you can use SHFileOperation to let the explorer do the work for you.

procedure TForm1.Button1Click(Sender: TObject);
 F : TShFileOpStruct;
 F.Wnd := Handle;    
 F.wFunc := FO_COPY;
 F.pFrom := 'A:\*.*';
 F.pTo := 'C:\TEMP\';
 if ShFileOperation(F) <> 0 then ShowMessage('Copy Failed');

sirk033097Author Commented:
Edited text of question
sirk033097Author Commented:
Wrong OS still using 16 bit. But the answer would have been excellent if I would be running the 32 bit windows OS.
then, only other solution, except for writing a lot of code, seems to be shelling out to xcopy.
try using something like this
WinExec('xcopy /S a:\*.* c:\temp'; SW_SHOWNORMAL);

you can also do a FindWindow loop to wait until the operation ends.
the problem with this approach is almost no error-handling.

if you go for code, then on this page
in the Files & Drives section you will find a number of components that will do enumerating/copying for you.
Your code will have to glue them together.

This won't do a whole structure, but you can use it to copy one file at a time.  CopyFile is a windows API function.

source, dest: string;

source := 'C:\document.txt';
dest := 'A:\document.txt';

CopyFile(pchar(source), pchar(dest), false);
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.