Solved

Copying files from a disk

Posted on 1997-03-30
5
156 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

24 Experts available now in Live!

Get 1:1 Help Now