Solved

Copying files from a disk

Posted on 1997-03-30
5
157 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
ID: 1335069
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
ID: 1335070
Edited text of question
0
 

Author Comment

by:sirk033097
ID: 1335071
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
ID: 1335072
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
ID: 1335073
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

825 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