Solved

Copying files from a disk

Posted on 1997-03-30
5
155 Views
Last Modified: 2010-04-06
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
Comment
Question by:sirk033097
  • 2
  • 2
5 Comments
 

Accepted Solution

by:
zodik earned 25 total points
Comment Utility
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
 

Author Comment

by:sirk033097
Comment Utility
Edited text of question
0
 

Author Comment

by:sirk033097
Comment Utility
Wrong OS still using 16 bit. But the answer would have been excellent if I would be running the 32 bit windows OS.
0
 

Expert Comment

by:zodik
Comment Utility
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
 
LVL 1

Expert Comment

by:sleach
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now