Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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
0
sirk033097
Asked:
sirk033097
  • 2
  • 2
1 Solution
 
zodikCommented:
on win95/nt4 you can use SHFileOperation to let the explorer do the work for you.


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


0
 
sirk033097Author Commented:
Edited text of question
0
 
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.
0
 
zodikCommented:
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
http://carbohyd.siobc.ras.ru/torry/VCLFR.HTM
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.



0
 
sleachCommented:
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.

var
source, dest: string;

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

CopyFile(pchar(source), pchar(dest), false);
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now